Global var vs shared instance vs class

This isn't just a simple sharing data between two view controllers. I have variables or class that defines a 'skin' for my app. So the user gets a popover GUI, can make a lot of changes to font, color, images etc in a lot of view controllers. I'm working the "Apple" way of doing this. Once the user finishes the config and pushes refresh I want all of the VC's to update. There are many VC's shown at any one time.


So in a nutshell, how to do global app skinning?

Accepted Answer

The "Apple" way would probably be to use an NSNotification. Any VCs that care about a change could register for that notification and update their UI accordingly. You could either include in the notification's user data a reference to some object that encapsulates all the UI details, or more likely just use a global singleton (since your VCs would need to query something for the initial settings when they are first displayed anyway - you can't use a notification there).


You can also take a look at appearance proxies (UIAppearance). It is meant for that sort of thing too. But you might need the notifications anyway if any code at all needs to run in response to the GUI change.

Works for me. Thanks

Global var vs shared instance vs class
 
 
Q