error handling - ios checking for an empty object -


i have error getting passed reference code found online. error comes empty object meaning there no error.

if check error.code bad access because object empty.

if check error == nil false because error empty object.

how can use logic find error exists, empty?

errors of type nserror or subclass of it. passed references in methods declared way:

-(void)dosomestuff:(nserror **)error; 

so, when call method requires pass reference nserror call way:

nserror *error = nil; [self dosomestuff:&error]; 

when method finished work check if error object has filled something:

if(error) {    //do stuff if there error.    //to see human readable description can:    nslog(@"the error was: %@", [error localizeddescription]);    //to see error code do:    nslog(@"the error code: %d", error.code); } else //there no error proceed normal {   //do other stuff - no error } 

p.s. if no error , method not behave expected there wrong implementation method. if it's open source stuff, coding mistakes can appear, can take @ method does, debug , fix if wrong...


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -