iOS Build a Simple iPhone App with Objective-C Views and View Controllers IBActions and IBOutlets

help please. very stuck

i'm not sure what i'm doing wrong.

2 Answers

Steve Hunter
MOD
Steve Hunter
Treehouse Moderator 57,564 Points

Hi there,

In the .m file, where the comment says to add the code, you need to add a line that modifies the text in the quoteLabel defined in the .h file. That looks like:

    self.quoteLabel.text = @"A stitch in time saves nine.";

You access the label with the self keyword then append using dot notation the name of the label, quoteLabel. Then to access the text property, you chain more dot notation onto that. Then you assign the given string to it using the equals sign and not forgetting the @ symbol for the string literal.

I hope that helps.

Steve.

thank you!

Jason Anders
MOD
Jason Anders
Treehouse Moderator 144,852 Points

Hey there,

I'm still relatively new to Objective-C and iOS, so I'm not sure how well I can explain this answer.

The challenge wants you to 'add' the text when the button is pressed. So inside the implementation file for ViewController (ViewController.m), you add the text to the quoteLabel. Because you are in the method, you need to use self to assign the text to it. The correct code snippet is below. The only line we added is below the 'add your code here'.

I'm sorry if I couldn't make more sense. I'm just beginning to understand all the "Whys?" myself.

Keep Coding! :)

- (IBAction)quoteButtonPressed {

    //Add your code below!
  self.quoteLabel.text = @"A stitch in time saves nine.";

}

thank you!