Finding a bug using Xcode - attempt to insert nil value

前端 未结 5 1482
温柔的废话
温柔的废话 2021-02-10 15:17

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

相关标签:
5条回答
  • 2021-02-10 15:27

    Try this:

    if([myDictionary objectForKey:@"string"]!= nil && [myDictionary objectForKey:@"string"]!= Nil) { }
    
    0 讨论(0)
  • 2021-02-10 15:30

    Have you turned on exception breakpoints? Click the + at the bottom left of the Breakpoint Navigator, then select Add Exception Breakpont.

    enter image description here

    You can right click the breakpoint to edit it…

    enter image description here

    This will cause the code to stop at the point where the error occurs.

    0 讨论(0)
  • 2021-02-10 15:33

    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.

    0 讨论(0)
  • 2021-02-10 15:42

    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

    0 讨论(0)
  • 2021-02-10 15:45

    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.

    0 讨论(0)
提交回复
热议问题