Вопрос

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