Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7995443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:24:56+00:00 2026-06-04T14:24:56+00:00

I have a mutable array with the following contents: 2012-05-26 23:38:09.606 [8147:f803] log (

  • 0

I have a mutable array with the following contents:

2012-05-26 23:38:09.606 [8147:f803] log (
        {
        send = david;
        receive = mike;
        message = test me;
    },
        {
        send = david;
        receive = daddy;
        message = test me;

    },
        {
        send = david;
        receive = daddy;
        message = test me;

    }
)

I am finding duplicates values like this:

NSSet *uniquearray = [[NSSet alloc] init];
uniquearray = [[NSSet setWithArray: myArray] valueForKey:@"receive"];

2012-05-26 23:38:09.609  [8147:f803]  log (
    mike,
    daddy
)

But if I want retrieve the message how I can do this? I just want something like take (rebuild an nsarray maybe)

2012-05-26 23:38:09.609 [8147:f803]  log (
   {
       receive = mike,
       message = test me;
},
{
       receive = daddy
       message = test me;
})

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T14:24:58+00:00Added an answer on June 4, 2026 at 2:24 pm

    You need to clarify your thinking about what you want. For example, what if the two messages to “daddy” had different content? Which one would you want? Or would you want to keep both?

    If you want to keep all unique messages and don’t care about the order, you can do:

    NSSet* uniqueSet = [NSSet setWithArray:myArray];
    

    If you can require iOS 5.0 or later, you can use NSOrderedSet to retain the order:

    NSOrderedSet* uniqueSet = [NSOrderedSet orderedSetWithArray:myArray];
    

    If you only want to keep one message from each receiver, you can do something like this:

    NSMutableArray* uniqueArray = [NSMutableArray array];
    NSMutableSet* seen = [NSMutableSet set];
    for (NSDictionary* dict in myArray)
    {
        NSString* receiver = [dict objectForKey:@"receiver"];
        if (![seen containsObject:receiver])
        {
            [uniqueArray addObject:dict];
            [seen addObject:receiver];
        }
    }
    

    As an aside, you should not name a variable uniquearray when it’s not an array but a set. Second, this code:

    NSSet *uniquearray = [[NSSet alloc] init];
    uniquearray = [[NSSet setWithArray: myArray] valueForKey:@"receive"];
    

    Allocates one empty set and then throws away the pointer to it, replacing the pointer with a pointer to a different set. The first object is entirely wasted. If you’re not using ARC, it’s also leaked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following mutable array: NSMutableArray *persons = [[NSMutableArray alloc]initWithObjects:person1, person2, person3, nil];
I have mutable string array named arrayout. It is having 3 element .Now I
I have an mutable array, allRows . In a loop, I assign each index
I have a mutable array that has about 100 objects in it and each
I have a mutable array that is retained and storing several objects. At some
If I have a mutable array codes in an NSMutableDictionary categorize NSMutableArray *myMutableArray=(NSMutableArray*)[categorize objectForKey:@codes];
I've been having a really weird problem. I have a mutable array that is
I have a sorted mutable array of a class called Topic. The topics represent
I have a one-time need to create a file from an iOS mutable array.
I have a mutable array that has been retained. This array contain dictionaries with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.