• 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: Removing duplicates from NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing duplicates from NSMutableArray


  • Subject: Re: Removing duplicates from NSMutableArray
  • From: Dan Wood <email@hidden>
  • Date: Mon, 02 Dec 2002 18:26:13 -0800

Well, if you're just using dummy values as the objects in a dictionary, then why not just use an NSSet instead?

On Monday, December 2, 2002, at 02:47 PM, Sherm Pendley wrote:

On Monday, December 2, 2002, at 05:05 PM, Jan Van Tol wrote:

What is the best way to filter out duplicate NSStrings from an NSMutableArray?

Traditional Perl wisdom is that, whenever you find yourself using the words "unique" or "duplicate," you should be thinking about a hash instead of an array. In Objective-C terms, that would be an NSDictionary instead of an NSArray. That is, when you're building the list, instead of doing this:

[myArray addObject: aString];

Do this:

[myDictionary setObject: @"" forKey: aString];

sherm--

--
Dan Wood
Karelia Software, LLC
email@hidden
http://www.karelia.com/
Watson for Mac OS X: http://www.karelia.com/watson/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Removing duplicates from NSMutableArray
      • From: John Timmer <email@hidden>
    • Re: Removing duplicates from NSMutableArray
      • From: "John C. Randolph" <email@hidden>
References: 
 >Re: Removing duplicates from NSMutableArray (From: Sherm Pendley <email@hidden>)

  • Prev by Date: NSToolbars and keyboard navigation
  • Next by Date: Re: Removing duplicates from NSMutableArray
  • Previous by thread: Re: Removing duplicates from NSMutableArray
  • Next by thread: Re: Removing duplicates from NSMutableArray
  • Index(es):
    • Date
    • Thread