user1429192
user1429192

Reputation: 13

Why do I see "undeclared identifier" in Xcode?

I recently started a book knowing nothing about Macs or Xcode called Beginning iOS 5 Development. I'm in chapter 4 and either I made a mistake or they made a typo. I cannot figure it out, so here's the problem:

- (IBAction)textFieldDoneEditing:(id)sender {
    [sender resignFirstResponder];
}


-(IBAction)backgroundTap:(id)sender {
    [nameField resignFirstResponder];
    [numberField resignFirstResponder];
}

- (IBAction)sliderChanged:(id)sender {
    UISlider *slider = (UISlider *)sender;
    int progressAsInt = (int)roundf(slider.value);
    sliderLabel.text = [NSString stringWithFormat:@"%d", progressAsInt];
}

@end

They told me to add the bold text after the sliderChanged method. Now Xcode is saying "use of undeclared identifier" so I can't run the app to preview on the iOS simulator. BTW, it says the problem is the sliderLabel.text.

Upvotes: 1

Views: 5544

Answers (2)

Hackless
Hackless

Reputation: 397

Second paragraph of page 98 describes how to name the label "sliderLabel". The label itself was created in the last paragraph of page 96. The critical thing here is to inspect the property of the label in assistant editor, and change the "Name" field of the label widget to "sliderLabel".

Upvotes: 0

BoltClock
BoltClock

Reputation: 723388

Make sure your header file has an IBOutlet UILabel *sliderLabel in the interface declaration (and that it is connected to a label in your view).

Upvotes: 1

Related Questions