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

Fun Facts App

What is wrong with this code? Xcode says the problem is in this line; let factProvider = factProvider(). Also, there is a problem in the last two lines.

// // ViewController.swift // Fun Facts // // Created by Macbook air 11 on 12/16/16. // Copyright © 2016 Macbookair11. All rights reserved. //

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var funFactLabel: UILabel!
let factProvider = factProvider()

override func viewDidLoad() {
    super.viewDidLoad()

    funFactLabel.text = factProvider.randomFact()
    }

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
    }

    @IBAction func showFact() {
   funFactLabel.text = factProvider.randomFact()
    let newColor = UIColor(red: 223/255.0, green: 86/255.0, blue: 94/255.0, alpha: 1.0)

        view.backgroundColor = randomColor
        funFactButton.tintColor = randomColor

}

}

1 Answer

Just a couple of questions

  1. Where did you get the factProvider() object from? Are you sure you have the correct name and not "FactProvider()"
  2. Where did you get the property "randomColor" from? Or was this a mistake and it suppose to be "newColor"