Returning an NSString from an NSError

tarnfeld picture tarnfeld · Mar 7, 2010 · Viewed 38.5k times · Source

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? :)

Answer

kennytm picture kennytm · Mar 7, 2010

-[NSError localizedDescription].

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