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 Simple iPhone App with Swift Views and View Controllers IBActions and IBOutlets

How would I access the text attribute for the label and set the String? quoteLabel.text = "A stitch in time saves nine"?

This is not compiling

Sure. The objective was to set the text of the UILabel by using the text attribute on the class. When I click check work this is not compiling. I included the code below.

class viewController: UIViewController {

@IBOutlet weak var quoteLabel: UILabel!

@IBAction func quoteButtonPressed() {
    //Your code here!
    quoteLabel.text = "A stitch in time saves nine"
}

}

3 Answers

Bradley Maskell
Bradley Maskell
8,858 Points

Trey Thompson Everything you have in your code is correct, you're just missing the period at the end of the string.

class viewController: UIViewController {

    @IBOutlet weak var quoteLabel: UILabel!

    @IBAction func quoteButtonPressed() {
        //Your code here!
        quoteLabel.text = "A stitch in time saves nine."
    }

}

lol thanks. That was driving me crazy.