I have an error getting passed by reference to some code I found online. The error comes back as an empty object meaning there was no error.
if I check for error.code I get a bad access because the object is empty.
if I check for error == nil I get a false because error is an empty object.
How can I use logic to find that the error exists, but is empty?
Errors are usually of type
NSErroror a subclass of it. They are passed as references in methods declared this way:So, when you call a method that requires you to pass a reference to a
NSErroryou call it this way:When this method finished its work you check if the error object has actually filled with something:
P.S. If you get no error and the method does not behave as expected then there is something wrong with the implementation with this method. Especially if it’s an open source stuff, coding mistakes can easily appear, so you can take a look at what the method does, debug and even fix if something is wrong…