How do you convert an iPhone OSStatus code to something useful?
No. Not completely.
Some OSStatus are four-character-codes, so you can use (extracted from iPhone SDK's sample code "CAXException.h
")
static char *FormatError(char *str, OSStatus error)
{
// see if it appears to be a 4-char-code
*(UInt32 *)(str + 1) = CFSwapInt32HostToBig(error);
if (isprint(str[1]) && isprint(str[2]) && isprint(str[3]) && isprint(str[4])) {
str[0] = str[5] = '\'';
str[6] = '\0';
} else {
// no, format it as an integer
sprintf(str, "%d", (int)error);
}
return str;
}
(See iOS/C: Convert "integer" into four character string for some more ways to convert fourcc into string, including Swift)
NSError's NSOSStatusErrorDomain is able to decode some OS errors. See @tomk's answer.
If you don't need to decode the number in program for the user, you may use the macerror
script to manually find out the meaning, as mentioned in @lros's answer. The list of OSStatus supported can be found from its source code in /System/Library/Perl/Extras/5.18/Mac/Errors.pm
.
There is also an online service http://osstatus.com/ collecting errors from all public frameworks. They are still not really complete e.g. the mapping to -12792
mentioned in the comment is missing. Probably it is a code from a private framework.
OSStatus error 1718449215
1718449215 is the decimal representation of the four character code for the kAudioFormatUnsupportedDataFormatError
error.
In general you can use something like this to get more information from the errors you receive:
NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain
code:my_error_code
userInfo:nil];
NSLog(@"Error: %@", [error description]);
Related Topics
Wkwebview Didn't Finish Loading, When Didfinishnavigation Is Called - Bug in Wkwebview
Calculating Tiles to Display in a Maprect When "Over-Zoomed" Beyond the Overlay Tile Set
Uiviewcontroller Prevent View from Unloading
Error: Uiview's Window Is Not Equal to Another View's Window
iOS Unable to Find Plugins, Android Fine
Create Uicollectionviewcell Subclass with Xib
How to Center Crop an Image in Swiftui
Atomic Properties VS Thread-Safe in Objective-C
Opengl Es 2.0 Object Picking on iOS
How to Delete Derived Data and Clean Project in Xcode 5 and Later
Crashlytics iOS - Log Caught Exception
Limiting User Input to a Valid Decimal Number in Swift
Using Collectionview in Uiview with Xib File
How to Tell If Your Code Is Running on an iPhone or an Iphone3G