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 6661523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:17:25+00:00 2026-05-26T02:17:25+00:00

I have a array of info that has multiple Names that I want to

  • 0

I have a array of info that has multiple Names that I want to match and count then move to a table view such as you would see on a messages app.

I have reached to this point. Where I can log and see what I want but simply can not find any solution pulling that info from the set and placing into a tableview accordingly.

example

- (void)directMessagesReceived:(NSArray *)messages forRequest:(NSString    
*)connectionIdentifier{

for(NSDictionary *d in messages) {

  // NSLog(@"See Direct Messageges Parsing Info: %@", d);

    Tweet *tweetDic = [[Tweet alloc] initWithTweetDictionary:d];


    //[directMessages addObject:tweetDic];
    [tweetDic autorelease];



}

//[arayToScan addObject:[messages valueForKey:@"sender_screen_name"]];
[arayToScan addObjectsFromArray:messages];
[self checkForDuplicateIDs]; 
// NSLog(@"Same ScreenName Received: %@", arayToScan);

//[self.mainTableView reloadData];    
 NSLog(@"DM COUNT = %i",[directMessages count]);

[DSBezelActivityView removeViewAnimated:YES];


}



- (NSSet *)checkForDuplicateIDs {

//CHECK FOR DUPLICATES IN ARRAY
NSArray *allIDs = [arayToScan valueForKeyPath:@"sender_screen_name"];
NSArray *sortedIDs = [allIDs sortedArrayUsingSelector:@selector(compare:)];

NSString *previousID = nil;
duplicateIDs = [NSMutableSet set];
for (NSString *anID in sortedIDs) {
    if ([previousID isEqualToString:anID]) {
        [duplicateIDs addObject:anID];

    }
    previousID = anID;
}


//THEN REMOVE ANY DUPLICATES IN NEW ARRAY
NSCountedSet *countedSet = [NSCountedSet setWithArray:sortedIDs];
NSMutableArray *oneMess = [NSMutableArray arrayWithCapacity:[sortedIDs count]];
NSMutableArray *multipleMess = [NSMutableArray arrayWithCapacity:[sortedIDs count]];


for(id obj in countedSet) {
    if([countedSet countForObject:obj] == 1) {
        [oneMess addObject:obj];
    }
 for(id duplicatenames in countedSet) {
     if ([countedSet countForObject:duplicatenames]>1) {
         [multipleMess addObject:duplicatenames];
         [countedSet  countForObject:duplicatenames];

     }


}


}
//NSLog(@"NSCountedSet = %@",[countedSet allObjects]);
 //NSLog(@"NSCountedSet = %@",countedSet);
//NSLog(@"One Message = %@",oneMess);
// NSLog(@"Multiple Messages = %@",multipleMess);


//HERE I HAVE ORIGINAL ARRAY IN ALBETICAL ORDER
// NSLog(@"Messages Containing more then 1 = %@",sortedIDs);    

//HERE I HAVE DUPLICATES IN ALBETICAL ORDER
// NSLog(@"Messages Containing more then 1 = %@",duplicateIDs);

//HERE I HAVE THE MESSAGES ONLY CONTAING 1
//NSLog(@"Messages Containing only 1 = %@",oneMess);


//NOW I WANT TO COUNT THE DUPLICATES TO PLACE AS A STRING IN CELL FOR # OF MESSAGES & #   
OF ROW IN TBLVIEW
//NSLog(@"Duplicates count = %i",[duplicateIDs count]);
// NSLog(@"Messages Containing only count = %i",[oneMess count]);

//HERE I WOULD ADD BOTH ARRAYS AND SEND TO MY ARRAY BELOW WHICH IS USED FOR MY TBLVIEW
THIS INFO IS RETRIEVABLE WHAT I NEED IS THE # OF EACH DUPLICATE AS SEEN 

//ARRAY *NEWARRAY INIT WITH OBJECTS ,ONEMESS, MULTIPLEMESS,
//ARRAY CUSTOM # OF EACH MULTIPLE MESSAGE TO SHOW IN TBLVIEW???

 //THEN I CAN CONTINUE WITH THE BELOW METHOD TO RELOD THE TABLEVIEW
//[directMessages addObject:NEWARRAY];
//[self.mainTableView reloadData];


return [[duplicateIDs copy] autorelease];

}

This is the log… this happens as many times as it counts but I just logged it to see if it was working which its is. Any help would be greatly appreciated

Counted = <NSCountedSet: 0x6d8cb80> (Nkapoor124 [33], iphonetechtips [3], jima6636 [4], pro1995 [2], iphone266 [2], eenofonn [1], iphoneMaster323 [3], FreeAppl3 [2], Bababooey13 [7], _CL1CK_ [5], _ToyVan_ [4], Nucleiosis [26], dracossaint [6], AlexInHouston [1], FlybriTn [7], iOSGraphix [1], deckedsg [5], 19est80 [3], JHackstar [2], barsoverbeats [7], anonomys209 [5], 87whitestallion [1], bAdGigabit [55], Sgt_Impacto [3], Nazaroth [2], K_Nitsua [1], MannyIphone [6], iphoneman76 [3])
  • 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-05-26T02:17:26+00:00Added an answer on May 26, 2026 at 2:17 am

    In your clarification, you asked for the amount (number?) of each duplicate. You can get at the count below. If you’re looking for the number of times each is duplicated (instead of total count of each) then that’s count – 1 for each. If it’s count – 1 is 0, there’s no duplicates.

    I think you’re looking for NSCountedSet countForObject method.

    The sample below …

        NSArray *names = [NSArray arrayWithObjects:@"John", @"Jane", @"John", nil];
        NSCountedSet *set = [[NSCountedSet alloc] initWithArray:names];
    
        for (id item in set)
        {
            NSLog(@"Name=%@, Count=%lu", item, (unsigned long)[set countForObject:item]);
        }
    

    Will output:

    2011-09-30 01:00:50.665 Craplet[7854:707] Name=Jane, Count=1
    2011-09-30 01:00:50.679 Craplet[7854:707] Name=John, Count=2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I have a Table View that has been populated with 21 data:
I have a huge array that has to be read by different threads in
So I have an array. The array has string values inside that can change
I have function that has to write some data into database table, but after
I have array of strings, String[] data and it's 10 elements has value P
Say if I have an array and I want to check if an element
i need help building a function that display an associative array and i want
PROBLEM I have a nested PHP array that I need to populate from flat
I have a map that has checkboxes for users to select what they would
i have a table named member_photos that stores member_id , photo_id , photo_dir and

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.