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
james white
78,399 PointsBuild a Playlist Browser with Swift Recap of iOS Basics Challenge
Challenge Link:
Challenge Task 1 of 1
Let’s assume we have an IBOutlet of type UIButton, named timerButton, as a property in the ViewController.swift file. In the viewDidLoad method, set the title of the button to “Start” for the state configuration Normal. Hint: Check out the UIButton class reference
Does this challenge sound familiar?
It should.
It's basically worded almost the same as this challenge:
Let’s assume we have an IBOutlet of type UIButton, named timerButton, as a property in our view controller header file. In the implementation file, set the title of the button to “Start!” for the state configuration UIControlStateNormal. Hint: Check out the UIButton class reference in the documentation.
So all you have to do is search the forum for "setTitle:@"Start!" to bring up these posts:
https://teamtreehouse.com/forum/help-with-ios
...and you'll find this line:
[self.timerButton setTitle:@"Start!" forState:UIControlStateNormal];
..so you paste that into this challenge (changing "Start!" to "Start" of course)
and it gives you this error:
Bummer! You need to use the setTitle method on timerButton
So what gives!
It took me more than a moment to realize what was going on...
This is one of those new Swift courses (not an Objective-C course!)
Yes..they both deal with mobile iOS, but they use different coding.
Oh no (you say) ...now I've got to forget everything I've learned on Treehouse about Objective-C.
Sorry, 'fraid so!
(clearing neural-net wetware cache now...done!)
Thus I had to go back to the video:
At around time index 06:16, you'll see this line:
aButton.setTitle("Press me!", forState: .Normal)
Which means (translating that into what the challenge wants) the line should be something like:
timerButton.setTitle("Start", forState: .Normal)
...and suddenly you've passed what is probably your first Swift coded
challenge.
Happy Coding!
1 Answer
Caleb Kleveter
Treehouse Moderator 37,862 PointsThanks for the help James.
kjvswift93
13,515 Pointskjvswift93
13,515 PointsWhat specifically are you having trouble with in this challenge?