Can an objective C method signature specify an enum type? [duplicate]
Possible Duplicate:
Can an objective C method signature specify an enum type?
"VoiceName" is an enum, declared like this:
enum VoiceName {
PAD_RHYTHM,
PAD_RHYTHM2,
PAD_RHYTHM3,
PEEPERS,
ATMOSPHERE,
IMPULSE,
FAST_PULSE,
HAIRYBALLS_PADS,
KICK
};
The compiler doesn't seem to like me using it in a method signature like this:
-(void)pulseFiredWithSamplePosition:(float)position from: (VoiceName) voiceName;
开发者_JAVA百科It tells me expected ')' before 'VoiceName'. What's going on here?
You have to refer to it as enum VoiceName
:
-(void)pulseFiredWithSamplePosition:(float)position from: (enum VoiceName) voiceName;
Or you can typedef it:
typedef enum {
/* ... */
} VoiceName;
Then you can refer to it as VoiceName
.
Remember this is Objective-C, it needs to be from: (enum VoiceName) voiceName.
If you don't want to say enum
you can use a typedef.
精彩评论