• 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: Obj-C idioms for list based tasks
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Obj-C idioms for list based tasks


  • Subject: Re: Obj-C idioms for list based tasks
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 7 Apr 2008 07:48:30 -0700


On 7 Apr '08, at 5:33 AM, Paul Sargent wrote:

Can anybody suggest a good way to:

1) Given an ordered set of objects, create a new non-mutable ordered set,
with all the duplicates removed?
2) Given an ordered set of objects, create a new non-mutable ordered set,
with each entry being the output of a method applied to each entry of the
original array (e.g. Python map())?

No, there's nothing like that built-in, unfortunately.

Are there any ObjC shortcuts when doing things like this? Am I best writing
a category on top of NSArray the encompass these (and other) patterns? I'd
like to retain ordering, so using NSSet for (1) seems counter productive.

Category methods would be a clean way to do it; just put a prefix on your method names so they won't conflict with any methods Apple adds in the future.


The only nontrivial thing about implementing these is performance, and that's only an issue if you work on huge arrays.

—Jens

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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: 
 >Obj-C idioms for list based tasks (From: "Paul Sargent" <email@hidden>)

  • Prev by Date: Re: Is this a bug in Cocoa 'isLike' ?
  • Next by Date: Re: How inspect pending performSelectorOnMainThread ?
  • Previous by thread: Obj-C idioms for list based tasks
  • Next by thread: Re: Obj-C idioms for list based tasks
  • Index(es):
    • Date
    • Thread