I've got an application that's designed as follows:
AppController is a subclass of NSObject that deals with the main interface,
PrefsController is also a subclass of NSObject that deals with the preferences window and maintains arrays of persistent custom objects that both Controllers need to access.
Both Controllers have instance variables pointing to each other.
Right now, I have it set up so that when AppController needs to get a list of, say, configured "gizmos," it uses [prefsController gizmos] to get it. When it has modified a gizmo and the changes need to be saved to disk, it does [prefsController saveGizmos], which tells PrefsController to put the gizmo array into NSSharedUserDefaults and synchronize the defaults, etc.
This seems odd and inefficient for some reason. Since both Controllers need access to the same set of objects, it seems like it would make more sense to have them both read from a shared store like NSSharedUserDefaults. But then changes in one aren't reflected in changes in the other for some reason, and the two sets are constantly out of sync, and they could easily overwrite each other's changes if I have them save to UserDefaults separately. So what is the best practice in this case?
Also, I'm wondering if it would be better to do something like having PrefsController listen for a GizmosHaveChanged notification, instead of being told directly to saveGizmos. When is it better to use indirect communication like NSNotifications instead of direct messaging?