How do you convert an iPhone OSStatus code to something useful?

前端 未结 19 1583
执念已碎
执念已碎 2020-12-05 01:45

I am getting more than a little sick of this iPhone SDK and its documentation...

I am calling AudioConverterNew

in the documentation under Returns: it says \

19条回答
  •  感情败类
    2020-12-05 02:01

    Failing a description string, it's convenient to convert OSStatus values to strings that look like their four-character definitions. At least then you can grep headers in hopes of finding a comment about what the status means.

    // declaration:  extern CFStringRef CreateTypeStringWithOSType(OSType inType);
    
    OSStatus result = ...;
    
    if (result != noErr) {
        NSString *statusString = (NSString *)CreateTypeStringWithOSType(result);
        NSLog(@"Error while $VERBing: %@", statusString);
        [statusString release]; // because "Create..."
        statusString = nil;
    }
    

提交回复
热议问题