I can't seem to figure out how I should use a switch statement with my custom typedef enum. Xcode tells this error:
Statement requires expression of integer type (MyEnum *) is invalid.
this is my enum declared over the @interface in my header
typedef enum {
A, B, C, D, E, F, G,
Ab, Bb, Db, Eb, Gb,
CSharp, DSharp, FSharp, GSharp
} Tones;
this is my property:
@property(nonatomic) Tones *tone;
and this is my function to get the string value of the enum
- (NSString *)stringValue {
switch (self.tone) {
case GSharp:
return @"G#";
...
}
}
An enum has literal values (basically named integers), not object pointers. Thus it should be:
@property(nonatomic) Tones tone;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With