This is probably because either iOS5 did not throw an exception for this error (and should have, but now iOS6 throws one which is better than having erratic behavior later), or because you have some different behavior in iOS6 which makes your object nil
whereas it was not in iOS5.
Whatever the reason, you can add a Symbolic Breakpoint on the insertObject:atIndex:
symbol, so that it will break every time this method is called, wherever it is in your application (in your own code or not).
- Go to the "Breakpoints Navigator" view (Cmd-6 shortcut)
- Click on the "+" button to add a symbolic breakpoint
- Set the symbolic breakpoint to break when it hits the symbol
[NSArray insertObject:atIndex:]
Thus you can see when this is called with a nil
value for the first parameter and fix your problem where it occurs.
You can also instead add an Exception Breakpoint to break when an exception is thrown, thus knowing when in the code your exception occurs. This is another way to let you know which part of the code (your own or another) generate the exception.
Once the breakpoint has been hit and the program stops before the exception occurs, you can check in the call stack what part of your own code led to trigger this exception at the end.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…