Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Stefan Bjornsson
Stefan Bjornsson
3,362 Points

How to create an 'IBAction' for our button. Please define a method called 'buttonPressed' and make sure it returns an 'IBAction'.

Could anyone work this one out?

6 Answers

Stefan Bjornsson
Stefan Bjornsson
3,362 Points

Its like this, I just got ahead of myself:

- (IBAction)buttonPressed {
NSLog(@"Button Pressed");
}

then we assign a string within the method we created

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

The file you are given is the implementation of the view controller and you need to implement the buttonPressed method just like you did in the video. The method will be blank and in the next task you will be asked to do something inside the method you just created.

There's something wrong with that, because this:

‐ (IBAction)buttonPressed:(id)sender {}

Isn't working.

Nathaniel Smith
Nathaniel Smith
1,377 Points

Just to let the staff know, I'm having a hard time understanding the terms for this question on the quiz. I understand the concepts and then follow along in xcode, and then I get the the quiz and I don't understand what's being asked. For the future, it's not really useful for me to find the answers to the quiz, if I don't understand the concepts.

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

You need to implement a buttonPressed method.

- (IBAction) buttonPressed {

}

If there's anything specific that is confusing then please let me know and I can update the instructions accordingly.

Nathaniel Smith
Nathaniel Smith
1,377 Points

Also, the second half of the quiz question will accept "no change to your code" if you simply hit the "check answer" button. That should probably be fixed.

Jason Losito
Jason Losito
1,358 Points

I am following the instruction in the video and I put this in:

  • (IBAction)buttonPressed:(id)sender {

}

It did not work. So basically, you do not need to put the ":(id) sender" even if in XCode, that works fine?