Reputation: 1617
Is there any way to get the iPhone simulator to give an error or log a message when I try to access a method of a variable that is nil?
e.g.,
MyClass *p = nil;
[p doSomething];
Upvotes: 2
Views: 141
Reputation: 21883
Not sure if it's what you are looking for, but zombies might be helpful. Check out:
http://iosdevelopertips.com/debugging/tracking-down-exc_bad_access-errors-with-nszombieenabled.html
Upvotes: 0
Reputation: 16973
No, there isn't. This is expected behavior for Objective-C, and lots of code (including Apple's frameworks) depends on it. If you somehow were to disable it, many terrible things could happen. Instead, learn to familiarize yourself with it and incorporate it in your code.
Upvotes: 1