• 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: Remove Duplicates in a NSArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Remove Duplicates in a NSArray


  • Subject: Re: Remove Duplicates in a NSArray
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 1 Oct 2008 15:37:01 -0500

On Oct 1, 2008, at 6:29 AM, Rashmi Vyshnavi wrote:

Is there a way to remove dictionary item containing same values for a key
from a array of dictionaries?


E.g.
   NSDictionary *dict1 = [NSDictionary dictionaryWithObjectsAndKeys:@
"testVal",@"testKey",....,nil];
   NSDictionary *dict2 = [NSDictionary dictionaryWithObjectsAndKeys:@
"testVal1",@"testKey",....,nil];
   NSDictionary *dict3 = [NSDictionary dictionaryWithObjectsAndKeys:@
"testVal3",@"testKey",....,nil];
   NSDictionary *dict4 = [NSDictionary dictionaryWithObjectsAndKeys:@
"testVal",@"testKey",....,nil];

   NSArray *arrDicts = [NSArray
arrayWithObjects:dict1,dict2,dict3,dict4,nil];

In the above code I want to remove the multiple dictionaries containing
"testVal" and maintain only one dictionary containing "testVal" in the array
"arrDict".

I think you can achieve what you want by filtering with an NSPredicate.

Cheers,
Ken

_______________________________________________

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: 
 >Remove Duplicates in a NSArray (From: "Rashmi Vyshnavi" <email@hidden>)

  • Prev by Date: Re: Print report using WebView
  • Next by Date: Re: Finding other apps' paths - deterministically!
  • Previous by thread: Re: Remove Duplicates in a NSArray
  • Next by thread: Re: Remove Duplicates in a NSArray
  • Index(es):
    • Date
    • Thread