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 Intermediate Swift Properties Property Observers

Mirko Salvia
Mirko Salvia
4,028 Points

I have again the error about the compiler. It says that it requires macOS 12, but it's running on macOS 11.x

I think it's an error of the website... could you fix it please?

Thank you Mirko

observer.swift
class TemperatureController: UIViewController {
    var temperature: Double {
      didSet {
        if (temperature > 80) {
          view.backgroundColor = UIColor.red
        } else if (temperature < 40) {
          view.backgroundColor = UIColor.blue
        } else {
          view.backgroundColor = UIColor.green;
        }
      }
    }

    init(temperature: Double) {
        self.temperature = temperature
        super.init()
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        view.backgroundColor = .white
    }
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Mirko,

I'm not sure I understand?

I copied your code that you posted and pasted into the challenge and it passed, so there seems to be nothing wrong with the challenge or your code.

If you feel there is a technical problem, you should contact the Treehouse Support Team as the Community is mostly just students like you and me.

I hope you get this sorted. :) :dizzy:

Mirko Salvia
Mirko Salvia
4,028 Points

Thank you Jason. I think they have solved the issue.

Thank you Mirko