Finding a bug using Xcode - attempt to insert nil value

回眸只為那壹抹淺笑 提交于 2019-12-03 08:39:03

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:

  1. Open XCode
  2. 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.

Baljeet Singh

Try this:

if([myDictionary objectForKey:@"string"]!= nil && [myDictionary objectForKey:@"string"]!= Nil) { }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!