Skip to content

Instantly share code, notes, and snippets.

@zoul
Created October 19, 2010 08:21
Show Gist options
  • Save zoul/633827 to your computer and use it in GitHub Desktop.
Save zoul/633827 to your computer and use it in GitHub Desktop.
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];
}
@ShonFrazier
Copy link

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

@talha131
Copy link

In macOS easier way is to use SecCopyErrorMessageString.

NSString *errorMessage = [((NSString *)SecCopyErrorMessageString(errCode, NULL))autorelease];

@egormerkushev
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment