Why can't I switch an enum in Objective-C
enums, objective-c, switch-statement, xcode
Solution
An enum has literal values (basically named integers), not object pointers. Thus it should be:
@property(nonatomic) Tones tone;
Problem
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#"; ... } } ```