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
Oscar Walters
146 PointsNEED HELP! IOS IBAction Question?
Hi there, I started on treehouse a few days ago and dont fully understand what to do in this question and what its asking me to do.
Question: Assume we are creating an app to display random quotes. So far our app has 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 to an 'IBAction'
- #import "THViewController.h" 2.
- @implementation THViewController 4. 5.
- @end 7.
That was the question and I had to fill in the blank numbered spots. This question is in the course called "building a simple iphone app." Im really confused so could someone please help, sorry if this sounds like a stupid question im just a beginner.
5 Answers
Doron Antebi
1,555 Points- (IBAction) buttonPressed {
}
In the brackets is where you place the return type (IBAction) and right after the name of your method as you called it.
Sean Conrad
4,223 PointsOh my goodness, thank you. That was infuriating! I entered in the working code from my project and it didn't work! They really need to work on the way these challenges work, and there REALLY needs to be a "show answer" option.
Nate Brooklyn
iOS Development Techdegree Student 1,779 Pointsshow answer button would be good
Oscar Walters
146 PointsStill quite confused the question has several blank spaces and some are filled in with code. Im really confused i tried answering it a hundred different ways but with no success
Stan Shyshkin
8,629 PointsHey Oscar,
So at the moment you have this:
#import "THViewController.h"
@implementation THViewController
@end
The first part, #import, just bring in the THViewController into the mix. What you want to do is take what Doron wrote above "- (IBAction) buttonPressed {
}"
and enter that into that implementation of the THViewController before the ending of it. Such as:
#import "THViewController.h"
@implementation THViewController
- (IBAction) buttonPressed {
}
@end
-Stan
Oscar Walters
146 Pointsthank you so much Stan
Nate Brooklyn
iOS Development Techdegree Student 1,779 Pointsshow answer button would be good
all the best amit and doug