Design pattern for collection of items and many subsets
Design pattern for collection of items and many subsets
- Subject: Design pattern for collection of items and many subsets
- From: Trygve Inda <email@hidden>
- Date: Fri, 30 Apr 2010 13:24:13 +0000
- Thread-topic: Design pattern for collection of items and many subsets
I'm trying to determine the best way to build this for scalability,
performance and maintainability.
I have a Source List which at the top contains a "masterArray" of
NSDictionary items.
Below that I have several "dumbLists" and "smartLists" which are subsets of
the items in the masterArray as determined by the user directly or by
user-set criteria.
As the user selects a list (only one selectable at a time), I need to change
the contents of a table to reflect the current list items.
I am thinking that I use a single NSArrayController and just change its
content array as needed.
However, I'd like to be able to badge each list with the quantity of items
in that list which means if I edit one of the items, it might fall in or out
of one of the smart lists. In this case after each edit I need to rebuild
all the lists.... Or maintain a separate array for each list.
Also, if an item is deleted, it also needs to be removed from any lists it
might be in.
What is the best way to do this?
My masterArray on disk is actually a Dictionary with ID numbers as the key
and Dicts as the value (in the value dict is another key listing the ID) so
that individual items can be quickly located for add/remove.
Just looking for the best way to (a) maintain a collection of items as well
as many collections that are subsets of the main collection and (b) an easy
way to locate individual records (which is much easier with dict key/value
pairs than with searching through arrays.
I hope this is clear.
Trygve
_______________________________________________
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