Re: NSArray (unique Items matching x)
Re: NSArray (unique Items matching x)
- Subject: Re: NSArray (unique Items matching x)
- From: Steven Degutis <email@hidden>
- Date: Wed, 10 Feb 2010 21:33:20 -0500
You can do this using Key Value Coding, specifically using the collection
operators like @distinctUnionOfSets etc.
-Steven
On Wed, Feb 10, 2010 at 9:11 PM, Jens Alfke <email@hidden> wrote:
>
> On Feb 10, 2010, at 1:45 PM, Trygve Inda wrote:
>
> > iTunes seems to do this with the column browser... Eg when you select
> > "Classic Rock", it pulls up a list of Artists without duplicates in the
> > list... And does it very fast.
>
> But keep in mind that iTunes is a Carbon app, not Cocoa.
>
> > It seems like a Predicate is working here... When one clicks "Classic
> Rock",
> > that is added to the predicate as Genre="Classic Rock", but then how does
> it
> > extract the list of Artists from the master array since it doesn't want
> > duplicates?
>
> You're asking about iTunes' implementation, which we have no idea about. It
> seems to use some kind of custom database. What you're describing is a
> typical sort of database query (in SQL it would be like "select distinct
> artist from ...").
>
> At a low level, in your code you could use an NSMutableSet to collect
> together the artist results, which would remove duplicates. I'm sure this
> would get awkward to work with, though.
>
> Basically I think you're running into the limitations of your very simple
> data structure. You could come up with something more complex, or you could
> start using CoreData and let it manage the data storage and querying for
> you.
>
> —Jens_______________________________________________
>
> 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
>
--
Steven Degutis
http://www.thoughtfultree.com/
http://www.degutis.org/
_______________________________________________
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