Re: Design pattern for collection of items and many subsets
Re: Design pattern for collection of items and many subsets
- Subject: Re: Design pattern for collection of items and many subsets
- From: Quincey Morris <email@hidden>
- Date: Fri, 30 Apr 2010 15:48:03 -0700
On Apr 30, 2010, at 14:29, Trygve Inda wrote:
> What is the best way to arrange my arrays and Array Controllers for all this
> to happen on the fly without having to refilter all the previous messages?
>
> Eg it does not seem efficient to call
>
> [myArray filteredArrayUsingPredicate:predicate]
>
> (or similar) on each smartBox after each new message come in... As I may
> receive 100 messages in a fairly short time span.
The array controllers are not a factor in this design question -- you're going to need the filtering with your data model (because of the count, and because, more importantly, of your "filtertext", which cannot be constructed by array controllers).
The question itself is not a Cocoa question. If it's too expensive to re-filter the master array each time messages arrive, then your smartBoxes are going to have follow a caching strategy. (For example, they keep an array of already-filtered objects, and new messages are filtered *separately* and the survivors are added to the cache array. Full master-array filtering is only necessary when the filter itself changes.) Or some other cleverer strategy.
> I also really only want one copy of the data so if a user edits the message
> properties at all, it is reflected in all places where that message appears.
Make sure everything is changed KVO-compliantly.
> Do I need a separate ArrayController for each box? If so where does it's
> contentArray come from?
If you need any array controllers at all (which is not entirely clear), you need at most 2: one for the list of boxes, and one for the table that shows the contents of the current box. Don't try to design array controllers into your data model. It only leads to pain.
_______________________________________________
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