Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
6 NSError *error = nil; 7 NSStringEncoding enc; 8 NSString *str = [NSString 9 stringWithContentsOfFile: @"DoesNotExist" 10 usedEncoding: &enc 11 error: &error]; 12 if (nil != error) 13 { 14 NSLog(@"Error: %@", 15 [error localizedDescription]); 16 } |
A few of the methods that Apple introduced with OS X 10.2 take an NSString** as an argument. This is used to return a second value reporting an error. If the variable that this points to is nil after the call, the operation succeeded. If not, it contains a string describing error.