Reputation: 1607
I have an enum defined in a objective-c header that looks like this:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface CustomerAndProspectMapViewController : UIViewController<MKMapViewDelegate>
typedef NS_ENUM(NSInteger, TypeEnum)
{
PROSPECT,
CUSTOMER
};
@end
Then in the implementation I have a function that takes a TypeEnum as a parameter and uses a switch to run some conditional code:
-(void) handleTestNavigation:(NSString *)accountId :(TypeEnum)accountType
{
switch(accountType)
{
CUSTOMER:
{
[self performSegueWithIdentifier:@"customerDetails" sender:accountId];
break;
}
PROSPECT:
{
[self performSegueWithIdentifier:@"prospectDetails" sender:accountId];
break;
}
}
}
As you can see, both options for the enum have a corresponding path in the switch. Yet for some reason, I get a compiler warning saying
Enumeration values 'PROSPECT' and 'CUSTOMER' not handled in switch
Just to make sure, I put some breakpoints in that method. As the warning indicated, it fell though without ever hitting a case. I also tried renaming the enum values just to make sure they were not conflicting somewhere and still nothing. I'm completely stumped here. Any help would be much appreciated.
Upvotes: 1
Views: 792
Reputation: 42598
You forgot the keyword case
.
switch(accountType)
{
case CUSTOMER:
{
[self performSegueWithIdentifier:@"customerDetails" sender:accountId];
break;
}
case PROSPECT:
{
[self performSegueWithIdentifier:@"prospectDetails" sender:accountId];
break;
}
}
NOTE: The code you posted created two labels.
Upvotes: 5