Search code examples
ioserror-handlingextract-error-message

are there iOS equivalents of GetMacOSStatusErrorString and GetMacOSStatusCommentString


i am trying to make some sense of an error code being returned when setting the scheduledFileID to an AUFilePlayer. Previously when developing for OSX i used

const char* GetMacOSStatusErrorString(OSStatus err);

const char* GetMacOSStatusCommentString(OSStatus err);

but they are declared in Carbon CarbonCore/Debugging.h so they are not available to me in iOS . Does anyone know of an equivalent way of doing this on iOS ?


Solution

  • I'm using this kind of code to get understandable error codes:

    OSStatus ScheduledFilesIDSError = AudioUnitSetProperty(auFilePlayerUnit,kAudioUnitProperty_ScheduledFileIDs,kAudioUnitScope_Global, 0, &filePlayerFile, sizeof(filePlayerFile));
    if (ScheduledFilesIDSError == noErr)
    {
    }
    else
    {   
        printf("AudioUnitSetProperty[kAudioUnitProperty_ScheduledFileIDs] failed, Error Code:%ld,\n", ScheduledFilesIDSError);
        NSError *error = [NSError errorWithDomain:NSOSStatusErrorDomain code:ScheduledFilesIDSError userInfo:nil];
        NSLog(@"Error: %@", [error description]);
    }
    

    the resulting log in my case is like :

    Error: Error Domain=NSOSStatusErrorDomain Code=-50 "The operation couldn’t be completed. (OSStatus error -50.)"
    Error: AudioUnitSetProperty[kAudioUnitProperty_ScheduledFileRegion] failed (-50)