Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Decode OSStatus error codes into strings.
NSString *NSStringFromOSStatus(OSStatus errCode)
{
if (errCode == noErr)
return @"noErr";
char message[5] = {0};
*(UInt32*) message = CFSwapInt32HostToBig(errCode);
return [NSString stringWithCString:message encoding:NSASCIIStringEncoding];
}

revolc commented Apr 26, 2013

gr8t!

(NSString *) CreateTypeStringWithOSType(OSType inType); // ;-)

In macOS easier way is to use SecCopyErrorMessageString.

NSString *errorMessage = [((NSString *)SecCopyErrorMessageString(errCode, NULL))autorelease];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment