I have been using NSError in a few places but I don’t really grasp the concept behind it. Especially why it is used using a double pointer like this:
NSError *err = nil;
NSString *s = nil;
s = [NSString stringWithContentsOfURL:url error:&err];
So why can’t we just pass the variable errto the method, which is passed as “by-reference” anyway as far as I can tell.
Thanks for some clarification
This is one of the best descriptions around about NSError.
Actually your are passing not an object but a pointer to a pointer. With this, you can set your NSError before you send a message to an object to nil and only if an error occurs, your NSError will “suddenly” hold an value so that you can do stuff like this:
Otherwise you would have to create an instance of NSError before you send the message and than check for a property or something else if an error occured.