Last active
January 3, 2016 23:19
-
-
Save hlung/8534467 to your computer and use it in GitHub Desktop.
This is how to check if an `NSError**` or the data it points to is empty. Very straight forward, we check if pointer is nil before checking if the data it points to is nil.Doing `*error` on a nil pointer will raise an exception.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (void)errTest2:(NSError**)error { | |
// Use error object ONLY IF it is provided, otherwise it will CRASH!!! | |
if (error != NULL) { | |
NSLog(@"Creating error object..."); | |
*error = [NSError errorWithDomain:...]; | |
} | |
else { | |
NSLog(@"No error object provided, skip error object creation."); | |
} | |
} |
Sorry, fixed. Now checking against NULL
instead :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
*error will initially point to a nil pointer so the if block will always fail & move to else.