PHP Module

Home Cocoa tips Logging NSError messages
Logging NSError messages PDF Print E-mail
Written by Ivan Fernandes   
Tuesday, 23 March 2010 16:11

Many Cocoa methods use the NSError class in order to provide error feedback about their executions. In order to show the error, just use the code bellow:

 
- (void)logError:(NSError *)error {
    NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
    if(detailedErrors != nil && [detailedErrors count] > 0) {
        for(NSError* detailedError in detailedErrors) {
            NSLog(@"  DetailedError: %@", [detailedError userInfo]);
        }
    } else {
        NSLog(@"  %@", [error userInfo]);
    }
}
 
Last Updated on Wednesday, 24 March 2010 05:08
 
Copyright © 2017 Bright Idea Software. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.