Bronze Challenge - Easy vs. Correct


I’ve completed the Bronze challenge by having the App Delegate receive the notification and setting the backgroundColor like so:

self.window.rootViewController.view.backgroundColor = [UIColor grayColor];

This works fine and all, but I feel like this is the easy way versus doing the correct way. Here are my questions:
[ul]Is it adhering to the MVC pattern to modify the View in this way?
Should the Notification subscription be happening in the HeavyViewController? If not why?
Would it be better (more correct) to have the App Delegate get the Proximity message and then send a message to the HeavyViewController which then changes the color?[/ul]

Thanks for the advice!

  1. With MVC it is normal for a controller to change a property on a view like you’ve done.
  2. You could do it that way too. In this simple example it wouldn’t matter which object registered for the notification. Sometimes it is nice for the app delegate to handle system notifications if it then triggers custom notifications to your app, or calls methods on several objects.
  3. It could be. Again, with this simple example it doesn’t matter. If we were trying to modify the view in a more drastic way then I would agree with you that implementing a method that encapsulated that entire change of state would be a good design choice.