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
Zack Havlin
Courses Plus Student 357 PointsAssume we are creating an app to display random quotes. So far our app has a label and a button that have been added to the view. We need to create an 'IBAction' for our button. Please define a method called 'buttonPressed' and make sure it returns an 'IB
Can I get some help here? I feel stupid but its just not coming to me.. any help would be great.
2 Answers
Amit Bijlani
Treehouse Guest TeacherAs mentioned in the video. You need to implement a method called buttonPressed that returns IBAction.
- (IBAction) buttonPressed {
// task 2 code will go inside this method
}
ithanhpham
9,931 PointsI think ui causes some confusion because when you hit preview with the correct method skeleton built, it will kick back an error:
http://screencast.com/t/PWZYEEEtFYd
If I say 'Check Work' it will accept it.
Zack Havlin
Courses Plus Student 357 PointsZack Havlin
Courses Plus Student 357 PointsThanks Amit!
I dont remember hearing anything about methods. I apologize and dont wanna sound dumb!
Zack Havlin
Courses Plus Student 357 PointsZack Havlin
Courses Plus Student 357 Pointsimport "THViewController.h"
@implementation THViewController (IBAction) buttonpressed { self.buttonPressed.text = @"buttonPressed"; } @end
Zack Havlin
Courses Plus Student 357 PointsZack Havlin
Courses Plus Student 357 PointsI cannot figure this out
Amit Bijlani
Treehouse Guest TeacherAmit Bijlani
Treehouse Guest TeacherNo need to apologize. It's always confusing and scary when you are learning something new, which is why we have the forum. In the video when you created the
IBActionthe method was created for your within the.hand the.mfiles. In the code challenge you are asked to write out the method manually. The name of the method isbuttonPressed. What I wrote above is the answer for task 1.For task 2 you are asked to assign a string to the label property named
quoteLabel.