I'm not sure what you're looking for here. I'm not familiar with CommonCryptor or how error messages are handled in it.
I can recommend that you lean on NSError and it's userInfo and NSLocalized*Key feature.
For example, if you set a NSLocalizedDescriptionKey
in the userInfo dictionary, error:
NSDictionary userInfo = @{
NSLocalizedDescriptionKey : @"This is the error message I want users to see"
};
*error = [NSError errorWithDomain:kBridgeEncryptorErrorDomain
code:result
userInfo:userInfo];
Then This is the error message I want users to see
is the string returned by -localizedDescription
. Then the calling code can use the string to display a message to the user without needing to reinterpret it.
As to the question of how to link error codes to messages you want users to see, there could be a CommonCryptor function that converts error codes to human readable string. If not, then you could write your own. I would recommend using a switch.
NSString *MyCodeToLocalizedDescription(CCCryptorStatus cryptorStatus)
{
switch(cryptorStatus) {
case kCCDecodeError: return @"This is the error message I want users to see";
…
default: return @"Oh noes, unknown error";
}
}
At that point setting the error is:
NSDictionary userInfo = @{
NSLocalizedDescriptionKey : MyCodeToLocalizedDescription(result)
};
*error = [NSError errorWithDomain:kBridgeEncryptorErrorDomain
code:result
userInfo:userInfo];