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 2.0 Improving Our User Interface Changing the Background Color

Wojciech Pilwinski
Wojciech Pilwinski
1,723 Points

Bummer! Make sure you're adding a stored property to your subclass as specified in the directions

OK, it's again me :) so could you help me and tell me what wrong I do now. I stored property blueColor to the class ViewController, and gave it default value UIColor.blueColor(). "Preview" doesn't show any errors. So why can't I pass that challenge?

For any help, thanks in advance. Best Regards

colors.swift
class ViewController: UIViewController {
    var blueColor: UIColor = UIColor.blueColor()

    override func viewDidLoad() {
        // Do any additional setup after loading the view, typically from a nib.
    }

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

2 Answers

Wow! I can't believe they would do something like this! You work is fine. The editor is just insisting on a constant rather than a variable (without any hint to that effect):

let blueColor = UIColor.blueColor()
Pavel Bogart
Pavel Bogart
1,713 Points

the same error

sometimes it's quite annoying when you are coding in Xcode and everything is alright but when paste in to website field it doesn't work.

Curtis Bridges
Curtis Bridges
17,720 Points
// this works!
let blueColor = UIColor.blueColor()

is the correct answer, which threw me off as well -- although the error doesn't say it, the instructor must be looking for the constant (let) version of a stored property rather than the variable (var) version:

// doesn't pass the check
var blueColor = UIColor.blueColor()