I’m trying to write a method in objc with a parameter that takes optional numer of types. Like the autorezise property for UIView. Or this one:
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound)];
Example:
[object call:(TypeOne | TypeTwo | TypeThree)];
My guess is to define a method that takes a enum type like this:
- (void)call:(EnumType)type;
But then i have no idea how to act on the “type”. Can i use an if statement?
it’s declared as
there is an associated type. therefore, yes
- (void)call:(EnumType)type;is correct.to act on it: enum types behave like an int in many ways. you can if, compare, switch, and so on.