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 Working With Multiple View Controllers A Recap with UIButton

Setting a title quiz - bug?

This seems trivial and obvious so I'm thinking it's a bug in the quiz. It's the same exercise as presented in the PlaylistMasterViewController @IBOutlet, no?

ViewController.swift
class ViewController: UIViewController {

    @IBOutlet weak var timerButton: UIButton!
    var redColor: UIColor = UIColor.redColor()

    override func viewDidLoad() {
        super.viewDidLoad()
        timerButton.setTitle("Start", forState: . Normal)

    }
}

Forgot to mention that I get the following error:

"You need to use the setTitle method on timerButton."

Additionally, if I remove the forState declaration, I get an error stating that I need to specify that. Beyond that, if I specify some other title besides, "Start", I get an error saying that I need to set the title to the correct string. That all leads me to believe that what I have above is correct and that the treeshouse quiz app is a little drunk.

1 Answer

Nick Kohrn
Nick Kohrn
36,940 Points

Vince,

I just completed the challenge with this:

    class ViewController: UIViewController {

        @IBOutlet weak var timerButton: UIButton!
        var redColor: UIColor = UIColor.redColor()

        override func viewDidLoad() {
            super.viewDidLoad()

            //Add your code below
            timerButton.setTitle("Start", forState: .Normal)
        }
    }

Looks like you have a space between your enum case for the second argument to the setTitle:forState: method. You have . Normal. Just remove the space and .Normal should work for you.

Emmanuel Darmon
Emmanuel Darmon
6,115 Points

I tried to get some help with the documentation, but cannot figure out where is this piece of code... Can you help me to help myself? :) Where can I find this in the documentation?