How to track line causing runtime error?

My application failed message:

'NSInvalidArgumentException', reason: '- [__ NSCFDictionary setObject: forKey:]: try to insert the value nil (key: 0)'

and I'm trying to find where this is happening in my code. I set NSZombiesEnabled to environment variables, however it's pretty hard to determine the location. Any idea on how to debug?

I typed bt and this is what I see:

 frame #0: 0x30d1832c libsystem_kernel.dylib`__pthread_kill + 8
    frame #1: 0x3597d20e libsystem_c.dylib`pthread_kill + 54
    frame #2: 0x3597629e libsystem_c.dylib`abort + 94
    frame #3: 0x35055f6a libc++abi.dylib`abort_message + 46
    frame #4: 0x3505334c libc++abi.dylib`_ZL17default_terminatev + 24
    frame #5: 0x36c38356 libobjc.A.dylib`_objc_terminate + 146
    frame #6: 0x350533c4 libc++abi.dylib`_ZL19safe_handler_callerPFvvE + 76
    frame #7: 0x35053450 libc++abi.dylib`std::terminate() + 20
    frame #8: 0x35054824 libc++abi.dylib`__cxa_rethrow + 88
    frame #9: 0x36c382a8 libobjc.A.dylib`objc_exception_rethrow + 12
    frame #10: 0x3428d50c CoreFoundation`CFRunLoopRunSpecific + 404
    frame #11: 0x3428d36c CoreFoundation`CFRunLoopRunInMode + 104
    frame #12: 0x3826f438 GraphicsServices`GSEventRunModal + 136
    frame #13: 0x36d27cd4 UIKit`UIApplicationMain + 1080
    frame #14: 0x00051cdc AppName`main + 80 at main.m:16
+5
source share
3 answers

Add exceptions as a breakpoint. Assuming Xcode 4 + ...

  • At the top of the navigator’s frame (where you view files, etc.) you will see a small icon that looks like a side arrow.
  • . +, .
  • " ..."

, , ... .

, , , .

+9

? iTunes Connect?

, , , "bt" (gdb) stacktrace .

+1

AppDelegate:

void uncaughtExceptionHandler(NSException *exception);

void uncaughtExceptionHandler(NSException *exception) {
    NSLog(@"CRASH: %@", exception);
    NSLog(@"Stack Trace: %@", [exception callStackSymbols]);
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSSetUncaughtExceptionHandler(&uncaughtExceptionHandler);

// your previous code here
    return YES;
}

, , .

+1

All Articles