• 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
Re: CoreData - KVO on unarchived array/dictionary elements?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData - KVO on unarchived array/dictionary elements?


  • Subject: Re: CoreData - KVO on unarchived array/dictionary elements?
  • From: Terrence Talbot <email@hidden>
  • Date: Fri, 14 Oct 2005 16:43:02 -0700


On Oct 10, 2005, at 2:11 PM, Terrence Talbot wrote:


Say I have an object that has a reference to a StoredDictionary called pluginPropeties. Say further that one of the entries in the dictionary is an array called linkList. linkList itself is a regular NSArray of NSDictionarys containing various information about different links (title, URL, etc.). In the main this works fine, unless I use bindings.


The issue appears to be that when linkList comes out of cold storage, by essentially doing [NSPropertyListSerialization propertyListFromData:], and gets vended back to the other side of the binding, changing any of the items in linkList (or any of the entries in one of the dictionaries held by linkList) is never noticed by pluginProperties so the changes to the data are not put back in the datastore. (pluginProperties never gets setValue:forKey: when something is changed inside linkList)


Thought I would follow up and explain what I did to solve this. (A shorter version was also posted under the title "How do I observe changes in NSArray contents?".)


I basically solved the problem by avoiding it altogether. Rather than binding directly to the linkList key, I backed up a level and bound to pluginProperties.linkList. I then wrote a method

- (void)setPluginProperties:(id)aDictionary

that intelligently looked at the passed in aDictionary and put the key/value pairs back in the datastore through my dictionary-like NSManagedObject subclass. I then, and here's the real trick, turned on "Handle Content as Compound Value" in the array controller's contentArray binding. Now it just chunks up the changes within linkList and sends them back to the right place.

I'm back to (potentially) code-free plugins. Go Bindings!

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >CoreData - KVO on unarchived array/dictionary elements? (From: Terrence Talbot <email@hidden>)

  • Prev by Date: Re: Scheduling an application function/event
  • Next by Date: Re: Window Controllers Not Linking
  • Previous by thread: CoreData - KVO on unarchived array/dictionary elements?
  • Next by thread: printing header and footer when user says to scale
  • Index(es):
    • Date
    • Thread