• 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: NSArray (unique Items matching x)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSArray (unique Items matching x)


  • Subject: Re: NSArray (unique Items matching x)
  • From: Trygve Inda <email@hidden>
  • Date: Thu, 11 Feb 2010 03:34:08 +0000
  • Thread-topic: NSArray (unique Items matching x)

> 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.
>>

Many thanks... It seems @distinctUnionOfSets will work nicely here.

Cheers,

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

References: 
 >Re: NSArray (unique Items matching x) (From: Steven Degutis <email@hidden>)

  • Prev by Date: [MEET] CocoaHeads-NYC tomorrow (Thursday) night
  • Next by Date: Re: Using NSKeyedArchiver to save and restore state on iPhone apps
  • Previous by thread: Re: NSArray (unique Items matching x)
  • Next by thread: [iPhone 3.1] navigationItem.backBarButtonItem weirdness
  • Index(es):
    • Date
    • Thread