I want to get some useful information from NSError
.
If I print out [error userInfo]
, I get the following:
{
NSFilePath = "/Users/apple/Library/Application Support/iPhone Simulator/5.1/Applications/08260B6A-4D65-48DF-ADD1-FFC8750081E8/Documents/abc";
NSUnderlyingError = "Error Domain=NSPOSIXErrorDomain Code=17 \"The operation couldn\U2019t be completed. File exists\"";
}
I want to show the last line : "File exists", but how can i pick it out?
I tried:
localizedDescription
localizedFailureReason
localizedRecoverySuggestion
localizedRecoveryOptions
recoveryAttempter
Non of them show "File exists".
Finally, I follow code for perfect NSError print. Thanks @jbat100 and @Peter Warbo, I add a little bit on them code:
NSDictionary *userInfo = [error userInfo];
NSString *errorString = [[userInfo objectForKey:NSUnderlyingErrorKey] localizedDescription];