Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Objective c enum value in form of string literal within single qoutes

Found enum declaration in AudioToolbox/AudioServices.h

enum
{
    kAudioSessionNoError                                =  0,
    kAudioSessionNotInitialized                         = '!ini',
    kAudioSessionAlreadyInitialized                     = 'init',
    kAudioSessionInitializationError                    = 'ini?',
    kAudioSessionUnsupportedPropertyError               = 'pty?',
    kAudioSessionBadPropertySizeError                   = '!siz',
    kAudioSessionNotActiveError                         = '!act',
    kAudioServicesNoHardwareError                       = 'nohw',
    kAudioSessionNoCategorySet                          = '?cat',
    kAudioSessionIncompatibleCategory                   = '!cat',
    kAudioSessionUnspecifiedError                       = 'what'
};

I don't really understand what this declaration actually is. Google doesn't provide any information. Any help please?

like image 758
Alexander N. Avatar asked Apr 01 '11 13:04

Alexander N.


1 Answers

These are called «four char codes»:

http://en.wikipedia.org/wiki/FourCC

They are converted to integers (32 bits, as they are 4 chars), but improved the readability comapred to numeric values. Apple uses this from a long time, mainly for OSStatus codes.

like image 65
Macmade Avatar answered Oct 21 '22 13:10

Macmade