How to get the NSError message in iOS?

Monish Kumar picture Monish Kumar · Aug 10, 2010 · Viewed 25k times · Source

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.

Answer

jtbandes picture jtbandes · Aug 10, 2010

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.)