I’ve read that sending messages to nil is allowed in ObjC and I understand that this is a part of the language and that there has been controversy about it, pro and con. I don’t want to open up a discussion about any of that.
I just want to know if there is a way, short of always having to test if (presumedInstance != nil), that I can get errors when trying to send a message to nil? It is not helping me when coding that I don’t get errors – makes it harder to determine where the code flaw is, etc.
Perhaps a setting or script in XCode?
No, there’s no way to do this. In fact, it’s a very important feature of Objective-C. I’d actually argue it’s more important for you to do the testing (
if (object), which is the same asif (object != nil)) because it forces you to consider the inputs and outputs of your functions and methods, and the code paths your application goes through. It might be frustrating at first, but it’s one of the things you get used to, and it makes life much easier.