Created
October 19, 2010 08:21
-
-
Save zoul/633827 to your computer and use it in GitHub Desktop.
Decode OSStatus error codes into strings.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *NSStringFromOSStatus(OSStatus errCode) | |
{ | |
if (errCode == noErr) | |
return @"noErr"; | |
char message[5] = {0}; | |
*(UInt32*) message = CFSwapInt32HostToBig(errCode); | |
return [NSString stringWithCString:message encoding:NSASCIIStringEncoding]; | |
} |
(NSString *) CreateTypeStringWithOSType(OSType inType); // ;-)
In macOS easier way is to use SecCopyErrorMessageString
.
NSString *errorMessage = [((NSString *)SecCopyErrorMessageString(errCode, NULL))autorelease];
Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gr8t!