I am getting a random bug in my app, which is causing it to crash. The problem I am facing is XCode doesn't tell me where the crash is happening only the below information. Can someone tell me how I can find out where I might be able to find the problem within the code? It must be crashing at the same point as when the app does crash it always shows the below.
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary
setObject:forKey:]: attempt to insert nil value (key: 0)'
* First throw call stack: (0x381e48bf 0x37d301e5 0x381e47b9 0x381e47db 0x381516bb 0x9237b 0x91121 0x8f0c5 0x8abc1 0x37b9d 0x8b68f
0x3550850f 0x381b0577 0x3813c0cf 0x3547c3fb 0x3547dc2b 0x8d005
0x3814322b 0x34495 0x32e31 0x3372d 0x30a59 0x3813e435 0x7b1df 0x7b88d
0x79e25 0x31ca650f 0x31ca5f01 0x31c8c4ed 0x31c8bd2d 0x37f12df3
0x381b8553 0x381b84f5 0x381b7343 0x3813a4dd 0x3813a3a5 0x37f11fcd
0x31cba743 0x89e8b 0x24a4) terminate called throwing an
exception(lldb)
Have you turned on exception breakpoints? Click the + at the bottom left of the Breakpoint Navigator, then select Add Exception Breakpont.
You can right click the breakpoint to edit it…
This will cause the code to stop at the point where the error occurs.
There is a solution that I usually use on my projects, setting up some special breakpoint.
To do that:
- Open XCode
- Goes to "View -> Navigators -> Show Breakpoint Navigators"
Now add some new breakpoints clicking the "+" button:
- Add exception breakpoint
- Add Symbolic breakpoint with symbol
[NSException raise]
- Add Symbolic breakpoint with symbol
objc_exception_throw
Run again your project, application will stop on the line that is causing your problems.
error is evident enough. in any of your line, where you are setting some object for dictionary, you key is nill, which is not allowed
your problem is that you are using setObject: forKey Method to NSDictionary just make it NSMutableDictionary then try this method you can't assign value for NSDictionary like you are trying it's only for NSMutableDictionary.
i hope you will get my point what i am try to say.
Try this:
if([myDictionary objectForKey:@"string"]!= nil && [myDictionary objectForKey:@"string"]!= Nil) { }