Create a gist now

Instantly share code, notes, and snippets.

Embed
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

This comment has been minimized.

Show comment
Hide comment
@revolc

revolc Apr 26, 2013

gr8t!

revolc commented Apr 26, 2013

gr8t!

@ShonFrazier

This comment has been minimized.

Show comment
Hide comment
@ShonFrazier

ShonFrazier Sep 15, 2014

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

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

@talha131

This comment has been minimized.

Show comment
Hide comment
@talha131

talha131 Jun 13, 2017

In macOS easier way is to use SecCopyErrorMessageString.

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

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