1

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;

It tells me expected ')' before 'VoiceName'. What's going on here?

Community
  • 1
  • 1
morgancodes
  • 25,055
  • 38
  • 135
  • 187
  • See also: http://stackoverflow.com/questions/707512/typedef-enum-in-objective-c – Adam Rosenfield Sep 16 '10 at 01:49
  • I'm going to flag this because it is pretty hard to double post the same question accidentally, so figure someone adminish might want to see if it was simple error or deep SO mystery – msw Sep 16 '10 at 01:49
  • @quixoto: I kept following the links thinking this guy has posted 100 duplicates. Time for more coffee. – dreamlax Sep 16 '10 at 02:26

2 Answers2

5

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.

mipadi
  • 398,885
  • 90
  • 523
  • 479
0

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.

Logan Capaldo
  • 39,555
  • 5
  • 63
  • 78