I'm trying to update an NSError
object with more information. For example, an api call may fail and I want to update the error object returned from the api class with view controller information (method name that caused error, client message, any additional info). There isn't a setter method for the UserInfo
dictionary and trying to set a value for the dictionary raises an exception (Not key value code compliant I believe). I thought about creating a new NSError
object with the updated user info, but I wasn't sure if I might lose information.
Question
What's the best way to update the user info dictionary of an NSError object?
Easiest way to do this would be to get a mutable copy of the
userInfo
dictionary and add whatever you like to that. Then you would have to create a newNSError
(since there is not setUserInfo: method) with the same domain and code as the original one.