-1

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?

Larme
  • 24,190
  • 6
  • 51
  • 81
Manolo
  • 469
  • 6
  • 20
  • Xcode is just the IDE and this question is about a syntax error in Objective-C code so the "objective-c" tag is better. It looks like you're missing a closing brace `}` in the .h file after the declaration of `NrOfQuestLabel`. –  Apr 07 '14 at 13:01
  • @Anna, sorry it was there I missed when copy/past... the error is in the .M file :( – Manolo Apr 07 '14 at 13:57
  • `(IBAction)NrofQuestChange:(UIStepper *)sender:` to `-(IBAction)NrofQuestChange:(UIStepper *)sender` – Larme Apr 07 '14 at 13:58
  • http://stackoverflow.com/questions/7779443/how-to-use-uistepper?rq=1 – DogCoffee Apr 07 '14 at 14:05

1 Answers1

0

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.

katzenhut
  • 1,742
  • 18
  • 26