In Cocoa programming, when dealing with NSError, why we are passing &error to a message instead of error?
NSError *error;
if (![managedObject.managedObje
When you call the method, you aren't giving it a pointer to an NSError, you're giving it a place to pass a pointer to an NSError back to you.
I often write
NSError *error = nil;
which makes it a bit more obvious that there nothing (interesting) in error
when you call -save:
. It's just a place you've set aside for the address in memory of an NSError object. If the method encounters an error, it creates an NSError object and writes the address of the object in error
to pass it back to you.