Search code examples
iosobjective-cmacos

What is OSStatus?


For example:

OSStatus AudioServicesCreateSystemSoundID (
   CFURLRef       inFileURL,
   SystemSoundID  *outSystemSoundID
);

In the Apple's documentation description of this function tells us that the returned value is a "result code". But what code? Why is it "OSStatus"?


Solution

  • As you've said, it's the result code of the function.

    Hovewer, different functions have different result codes that you can handle as you wish. for example, for Audio services, the current OSStatus codes are give in the documentation as:

    enter image description here

    So as you call your functions, you check the returnes OSStatus and if it's noErr (which is what 0 is), then you can continue with your next call, otherwise you handle the error accordingly.