iosobjective-cnserror

How to get the NSError message in iOS?


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.


Solution

  • To get error message only, use:

    NSString *msg = [error localizedDescription];
    

    But for logging more details, use %@ format, like:

    NSLog(@"Error: %@", error);