Skip navigation.
 
mlBindings - registering change notification for multiple keys
FROM : dreamcat7
DATE : Tue Jul 01 20:38:05 2008

Hi,
I have my application's data and settings stored in 2 plist file, each 
containing several/many keys.*

I would like to to save the changed items permanently in my data store 
after the user interacts with the ui. Control elements are bound to a 
settings NSDictionary in my data model.


For any bindings notifications, the following method

- (void)registerAsObserver
{
    [model addObserver:self forKeyPath:@"prefs.debug"
                   options:(NSKeyValueObservingOptionNew | 
NSKeyValueObservingOptionOld)
                   context:NULL];
}

will only register for observing one value at a time. However I may 
have a wide variety of controls and settings that need to trigger the 
same code to write out the dictionary to the plist file (or to any 
arbitrary data storage mechanism i might use). And cant write anything 
like  @"prefs.*" because this syntax does not constitute a valid key-
path.
And if there is any way to listen for all values within a path or set.

So i am looking at other ways. Can you listen for all objects held by 
an NSArray ? This might be a useful alternative.
Although probably very expensive to convert between NSDictionary <=> 
NSArray each time an element was changed.
But i might try to change my data representation and avoid the 
NSDictionary altogether.

Of course there is the method setKeys: 
triggerChangeNotificationsForDependentKey: however i did find all the 
explanations about this really difficult to follow.  Awhile back i 
tried doing with the apple example but unfortunately no luck. And 
don't the array of triggering keys need to be first registered 
individually anyway ? (perhaps thats why it failed to work for me).

Has anybody had successes with these or other method for multiple keys ?


*Note - no core data yet as i am a newbie and having core data in my 
app would be alot do all at once.
But if this kind of issue is solved by a core data feature please let 
me know.

Related mailsAuthorDate
mlBindings - registering change notification for multiple keys dreamcat7 Jul 1, 20:38
mlRe: Bindings - registering change notification for multiple keys Ken Thomases Jul 2, 10:16
mlRe: Bindings - registering change notification for multiple keys dreamcat7 Jul 2, 12:12
mlRe: Bindings - registering change notification for multiple keys Ken Thomases Jul 2, 12:25
mlRe: Bindings - registering change notification for multiple keys Ken Thomases Jul 2, 13:14
mlRe: Bindings - registering change notification for multiple keys dreamcat7 Jul 2, 16:06