• 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: Custom NSArrayController that manages its own array?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Custom NSArrayController that manages its own array?


  • Subject: Re: Custom NSArrayController that manages its own array?
  • From: Keary Suska <email@hidden>
  • Date: Tue, 18 Oct 2011 12:59:58 -0600

On Oct 18, 2011, at 11:44 AM, Jens Alfke wrote:

> To help bind my data model to AppKit tables, I’ve written a custom class that implements KVC collection accessors to define a mutable-array property. That is, it implements methods like -countOfEntries, objectInEntriesAtIndex:, insertObject:inEntriesAtIndex, etc. I can then bind this as the contentArray property of an NSArrayController, and use that controller to drive a table view and master-detail UI.
>
> I’d like to avoid using a separate class, though (so I can make this setup more easily reusable.) Is it feasible to subclass NSArrayController and put the collection access methods in the subclass? Then I’d just have an “EntryArrayController” class I could drop into my nib. From the docs I can’t figure out whether this is an appropriate thing to do.

There is no reason that an NSArrayController cannot manage its own content (in fact it is coded to do so), but the idea that the content would be "keyed" is odd, as there generally isn't any need to. I.e., the array controller would not bind to itself, and if any other array controller wants its content it can simply bind to arrangedObjects. So the whole collection KVC stuff is unnecessary.

In your subclass you could use the machinery afforded by automaticallyPreparesContent, or simply set the content on awakeFromNib or whenever it is needed.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

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: Custom NSArrayController that manages its own array?
      • From: Jens Alfke <email@hidden>
References: 
 >Custom NSArrayController that manages its own array? (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: Launching 10.5 app on 10.4
  • Next by Date: Re: Custom NSArrayController that manages its own array?
  • Previous by thread: Custom NSArrayController that manages its own array?
  • Next by thread: Re: Custom NSArrayController that manages its own array?
  • Index(es):
    • Date
    • Thread