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

Build a Playlist Browser with Swift Recap of iOS Basics Challenge

Challenge Link:

http://teamtreehouse.com/library/build-a-playlist-browser-with-swift/working-with-multiple-view-controllers/a-recap-with-uibutton

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:

http://teamtreehouse.com/library/build-a-playlist-browser-with-objectivec/working-with-multiple-view-controllers/uibutton-recap

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

https://teamtreehouse.com/forum/settintcolor-method-objective-c-playlist-builder-code-challenge-answers-i-figured-it-out

...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! :flushed:

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:

http://teamtreehouse.com/library/build-a-playlist-browser-with-swift/working-with-multiple-view-controllers/recap-of-ios-basics

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. :thumbsup:

Happy Coding!

What specifically are you having trouble with in this challenge?

1 Answer

Thanks for the help James.