I wrote following code in my app:
typedef enum{
PasswordModeEnter = 1,
PasswordModeSetNewPassword = 3,
passwordModeVerify = 5,
PasswordModeChange = 7,
PasswordModeDisabled = 9
}PasswordModes;
And I instantiated an object named PasswordMode.
- (id)initWithPasswordMode:(PasswordModes *)passwordMode nibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.PasswordMode = passwordMode;
}
return self;
}
I got an strange error when I wrote following code:
switch (self.PasswordMode) {
case PasswordModeChange:
//do something
break;
case PasswordModeDisabled:
//do something
break;
case PasswordModeEnter:
//do something
break;
case PasswordModeSetNewPassword:
//do something
break;
case passwordModeVerify:
//do something
break;
default:
break;
}
I got following error:
statement requires expression of integer type.
what is the problem and how can I solve it?
The problem is with this
ProblemModes *
The * should be removed.
PasswordModes is just an enum, your init method incorrectly indicates that it is a pointer. The init method signature should be as follows:
- (id)initWithPasswordMode:(PasswordModes)passwordMode nibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
Your property should be as follows:
@property (nonatomic,assign) PasswordMode passwordMode;
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