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.
A string containing the localized description of the error.
The core attributes of an NSError object are an error domain (represented by a string), a domain-specific error code and a user info dictionary containing application specific information.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With