Do you guys know if there is a nice way to set/modify a NSError
's localizedDescription after it has been instantiated other than recreating it? I didn't find any.
The NSError
class is - like many Cocoa classes - immutable.
However, the doc states for -localizedDescription
that:
By default this method returns the object in the user info dictionary for the key NSLocalizedDescriptionKey. If the user info dictionary doesn’t contain a value for NSLocalizedDescriptionKey, a default string is constructed from the domain and code.
So just use errorWithDomain:code:userInfo:
to create a new instance or copy and supply an appropriate user info.
Here's another nice introduction to the NSError class.