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 trialmrdanielovski
214 PointsI couldn't solve the question. How can i see answer?
I couldn't solve the question. How can i see answer?
class viewController: UIViewController {
@IBOutlet weak var quoteLabel: UILabel!
@IBAction func quoteButtonPressed() {
}
}
1 Answer
Jordan Aldujaili
5,852 PointsSo you have a label and a button. You want to change the label when you press the button. Since that is the action, you need to put your code below the button. Your code will consist of the quoteLabel, which you need to change the text. So you would need to call the text from the quote label by using "quoteLabel.text". This gives you access to modify the text for the label. Now the rest is like algebra --> x="foo", think of quoteLabel.text as X. quoteLabel.text = "foo" should change the current label to foo