views:

586

answers:

3

I am using the NSURLRequest class in my iPhone app, and the method that calls it returns an NSString which is great for when the connection goes through ok, but the issue is I need to convert the NSError into an NSString so I can either return it back or run some if() statements on it.

Any ideas? :)

A: 

-[NSError localizedDescription].

(Also, every ObjC object inherited from NSObject implements -description which returns an NSString.)

KennyTM
A: 

No worries :) I found that there are three main methods to the NSError which are

  • error (NSInteger)
  • domain (NSString)
  • userInfo (NSDictionary)

http://bit.ly/9WVKMc Hunting through the Apple Class Reference helped a bit ;)

tarnfeld
A: 

You could try the localizedDescription method, which returns a string.

More in the docs.

Abizern