I am having the method in my view controller as shown below:
- (void)parser:(PaymentTermsLibxmlParser *)parser encounteredError:(NSError *)error { NSLog("error occured"); }
Here I need to show the Actual error message in the NSError in my alert can any one suggest how to get it.
Information about an error condition including a domain, a domain-specific error code, and application-specific information.
The core attributes of an NSError object—or, simply, an error object—are an error domain, a domain-specific error code, and a “user info” dictionary containing objects related to the error, most significantly description and recovery strings.
The core attributes of an NSError object are an error domain (represented by a string), a domain-specific error code and a user info dictionary containing application specific information.
The latest version of objective C is 2.0.
Normally you'll want to use [error localizedDescription]
to get the text to show to the user.
Read the NSError documentation for more options.
For simple logging when developing, you can do NSLog(@"Error: %@", error)
. (That will give you 'localizedDescription' and everything else on your log in Xcode.)
To get error message only, use:
NSString *msg = [error localizedDescription];
But for logging more details, use %@
format, like:
NSLog(@"Error: %@", error);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With