Listing only unique attributes in a set of Core Data Objects
Listing only unique attributes in a set of Core Data Objects
- Subject: Listing only unique attributes in a set of Core Data Objects
- From: "Fletcher T. Penney" <email@hidden>
- Date: Fri, 27 May 2005 01:14:24 -0400
THE PROJECT
I am experimenting with Core Data (and much of Cocoa, actually) by
trying to expand on the iTunes playlist idea. To practice, I am
using a rather simple database:
A "Person" object has firstName and lastName attributes
A "Filter" object has filterType and predicateString attributes.
The two (for now) types of filters are:
a collection - this is analogous to a playlist - there is a
many-to-many optional relationship between Person and Filter that
defines a playlist
a filter - this filters down a playlist based on user
defined characteristics using predicates (currently built from a user
defined string)
Filter objects are in a NSTreeController (using parent and child
relationships), allowing you to combine collections and filters to
create fairly complex "playlist" algorithms to find only the people
you want. ( This much is working, and I will post the project files
when I get a chance and a little more of the functionality is
complete. )
I am trying to build as much of the logic as possible only using
Interface Builder and the Core Data model. So far, the only thing I
have had to do programatically is a function that builds a predicate
based on the hierarchy of Filter objects and their strings. The rest
(so far) is all done by connecting various controllers in IB.
THE NEXT STEP
I want to add the ability to interactively trim down the list of
people by using a series of arrays (similar to the browse feature in
iTunes)
For example, one array would list all firstNames, and by clicking on
one (or more) you can filter the table of people to only those
sharing the appropriate first names
After clicking on a firstName, the lastName array would list only the
last names of the available people matching the firstName(s).
THE PROBLEM
This part is pretty easy so far, but I would like for the array of
firstNames not to list duplicates. If two people are named John,
"John" should only appear in the array once.
There does not appear to be a means of telling Core Data to deliver
"the first person to have each firstName" out of all the people in
the database. Is there a way to do this within the Core Data realm
itself, or will it require a custom function to scan each person, and
remove the duplicates sharing a given firstName (or lastName, etc)???
Alternatively, pointers to example projects providing this sort of
behavior with Core Data would also be appreciated.
Thanks for any advice!!!!
Fletcher Penney
--
Fletcher T. Penney
email@hidden
Without question, the greatest invention in the history of mankind
is beer. Oh, I grant you that the wheel was also a fine invention,
but the wheel does not go nearly as well with pizza.
- Dave Barry
_______________________________________________
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