• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Bindings - registering change notification for multiple keys
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bindings - registering change notification for multiple keys


  • Subject: Bindings - registering change notification for multiple keys
  • From: dreamcat7 <email@hidden>
  • Date: Tue, 1 Jul 2008 19:38:05 +0100

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.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Bindings - registering change notification for multiple keys
      • From: Ken Thomases <email@hidden>
  • Prev by Date: Re: NSDateComponents question
  • Next by Date: Re: Struct, Object, or Dictionary?
  • Previous by thread: [MEETING] Toronto Area Cocoa & WebObjects Developer Group - July 8
  • Next by thread: Re: Bindings - registering change notification for multiple keys
  • Index(es):
    • Date
    • Thread