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 v5 Creating a Data Model Creating a Random Color Model

My code is not working like yours and you din't put your code files in the download this is my worst nightmare

// // ViewController.swift // RandomFact // // Created by logs on 29/09/2019. // Copyright © 2019 Wizard Team. All rights reserved. //

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var randomFactLabel: UILabel!

let randomFactProvider = RandomFactProvider()
let randomBackgroundColorProvider = RandomBackgroundColorProvider()

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.

    randomFactLabel.text = randomFactProvider.facts[0]
}

@IBAction func showAnotherFunFact() {

    randomFactLabel.text = randomFactProvider.randomFact()

}

}

1 Answer

Gregg Squire
Gregg Squire
14,829 Points

The same way that you are setting the text to the random fact in showAnotherFunFact(), you need to set the background color to the random color.