开发者

Can an objective C method signature specify an enum type? [duplicate]

This question already has answers here: Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜