I can't figure how to fix this Expected identi

2019-03-07 01:32发布

- (IBAction)SignUp:(id)sender;  {                                   Expected identifier or '('

    IBOutlet UITextField *Firstnamefield;
    IBOutlet UITextField *Lastnamefield;
    IBOutlet UITextField *emailfield;
    IBOutlet UITextField *agefield;
    IBOutlet UITextField *passwordfield:
    IBOutlet UITextField *reenterpasswordfield;
}

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-03-07 02:11

It seems to me that you put an IBAction at the wrong place in the .h file. It should be after the definition of the instance variables, for example:

@interface ViewController : UIViewController
{
    IBOutlet UITextField *Firstnamefield;
    IBOutlet UITextField *Lastnamefield; 
    // ...
}
- (IBAction)SignUp:(id)sender;

@end
查看更多
何必那么认真
3楼-- · 2019-03-07 02:21
- (IBAction)SignUp:(id)sender {
   UITextField *Firstnamefield;
   UITextField *Lastnamefield;
   UITextField *emailfield;
   UITextField *agefield;
   UITextField *passwordfield;
   UITextField *reenterpasswordfield;
}

There a couple of problems. For one, you can not use the IBOutlet qualifier outside of an interface declaration. And passwordfield has a colon after it that should be a semicolon.

In case this is the point of confusion, if you were creating the interface declaration for this IBAction, it would look like this:

- (IBAction)SignUp:(id)sender;

Other than that, the only other thing that could be causing this is if you are trying to place the entire IBAction inside the header file.

查看更多
登录 后发表回答