Frage

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?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top