• 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: NSArrayController array-observation
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArrayController array-observation


  • Subject: Re: NSArrayController array-observation
  • From: Dominik Wagner <email@hidden>
  • Date: Wed, 3 Dec 2003 18:07:20 +0100

Hi Scott,


On 26.11.2003, at 07:28, Scott Anguish wrote:
On Nov 25, 2003, at 8:01 PM, Dominik Wagner wrote:
On 25.11.2003, at 23:08, Scott Anguish wrote:
On Nov 25, 2003, at 10:00 AM, Dominik Wagner wrote:
On 23.11.2003, at 21:30, Scott Anguish wrote:
On Nov 23, 2003, at 2:05 PM, Dominik Wagner wrote:
Basically it's: How do I observe the contents of an Array?
You can only observe the contents of an array by registering as an observer on each item in the array. Yes, not the best solution for you're situation.
Yes, too much overhead for such a simple task.
I'm not sure how.. that's what would happen if the array automatically supported it.
Yeah, the overhead I mean is that I would have to observe the array and react on changes to make sure every content dictionary is observed too. And then of course the handling of the observation callbacks would be the same as when the array directly supported it.

this isn't that difficult though, since if you implement the indexed accessor methods for the property with the mutable array there is a single entrance point.

Hmm, I started implementing this, and it wasn as much work as I initially thought. Things worth mentioning:
- The indexed Accessors for to-many propertys only get called if you don't have normal accessors (-<key>, -set<key>)
- If you do not implement the indexed accessors, then although your returning a MutableArray in the -<key> accessor, the NSArrayController always set the whole array on change (addObject:)

And of course some Question arose:
- Following setup in RendezCon: The FoundServicesArrayController is bound to a NSMutableArray that has NSMutableDictionarys. One Key of this Dictionary is "addresses" which again is a NSMutableArray. Another ArrayController is bound to the FoundServicesArrayController selection.addresses. Now if you change the "address" Array inside the NSMutableDictionary, then the Table view controlled by the ArrayController does not get updated. You have to do an explicit setObject: forKey:@"addresses" on the corresponding MutableDictionary. This is quite bad, cause this causes the whole Array to be set again when only one address is added. Is there a way around this?

I know that this is of no great importance in this context, but as I want to produce good sample code I want to do it right nevertheless.

Cheers,
dom

--
Dominik Wagner Mail: email@hidden
TheCodingMonkeys http://www.codingmonkeys.de/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: NSArrayController array-observation
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: Allowing newlines in a NSTextField?
  • Next by Date: Re: Creating small controls programmatically
  • Previous by thread: Allowing newlines in a NSTextField?
  • Next by thread: Re: NSArrayController array-observation
  • Index(es):
    • Date
    • Thread