質問

Hi I am trying to add a stepper to my app but got this error:

ViewController.h:

@interface ViewController : UIViewController {    
      IBOutlet UILabel *NrOfQuestLabel;}
-(IBAction)NrofQuestChange:(UIStepper *)sender;

ViewController.m:

-(IBAction)NrofQuestChange:(UIStepper *)sender:{ double value = [sender value];
[NrOfQuestLabel setText: [NSString stringWithFormat:@"%d", (int)value]];
 }

Error in .m: !Expected identifier !"sender" used as the name of the previous parameter rather than as part of the selector

Any help?

役に立ちましたか?

解決

Unless its another typo, you have an extra colon in xour code right after sender:

-(IBAction)NrofQuestChange:(UIStepper *)sender:{ 
    double value = [sender value];
    [NrOfQuestLabel setText: [NSString stringWithFormat:@"%d", (int)value]];
 }

should be

-(IBAction)NrofQuestChange:(UIStepper *)sender{
    double value = [sender value];
    [NrOfQuestLabel setText: [NSString stringWithFormat:@"%d", (int)value]];
 }

Thats why the compiler can't decide whether sender is a variable or part of the method name.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top