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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:59:34+00:00 2026-05-23T01:59:34+00:00

I want to find similar strings in an array/dictionary and rename them by adding

  • 0

I want to find similar strings in an array/dictionary and rename them by adding a postfix to the string. For example suppose my array/dictionary contains strings like this:

1.Work
2.Work
3.Work
4.Home
5.Home
6.Mobile
7.Mobile 

etc. there could be any similar strings. Now I want to rename them like this:

1.Work(1)
2.Work(2)
3.Work(3)
4.Home(1)
5.Home(2)
6.Mobile(1)
7.Mobile(2)
  • 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-23T01:59:34+00:00Added an answer on May 23, 2026 at 1:59 am

    Well, i don’t know about a dictionary, but for an array you could do something like this.

        NSMutableArray *myArr = [fill the array with w/e];
        int home;
        int mobile;
        int work;
        for(int x = 0; x < [myArr count]; x++){
        NSString *r = [myArr objectAtIndex:(NSUInteger)x];
        if([r isEqualToString:@"work"]){
        work++;
        [myArr replaceObjectAtIndex:x withObject:[NSString strinWithFormat:@"%@(%i)", r, work]];
        }
        else if([r isEqualToString:@"home"]){
        home++;
        [myArr replaceObjectAtIndex:x withObject:[NSString strinWithFormat:@"%@(%i)", r, home]];
        }
        else if([r isEqualToString:@"mobile"]){
        mobile++;
    
        [myArr replaceObjectAtIndex:x withObject:[NSString strinWithFormat:@"%@(%i)", r, mobile]];
    
        }
        }
    

    Best of luck

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

Sidebar

Related Questions

I have 1000's of strings similar to CN=Joe Smith,OU=Students,DC=Domain,DC=Edu and I want to find
I have an array of strings as follow: [a1,a2,a1,a3,a2] I want to find the
I see many similar questions, however I want to find the Username of the
I want to compare several strings to each other, and find the ones that
I have an input string and a collection of strings and I want to
I am trying to capture sub-strings from a string that looks similar to 'some
In text i want to find structures like every thing till some text, but
I want to find records on a combination of created_on >= some date AND
I want to find a way to develop database projects quickly in Visual Studio.
I want to find any text in a file that matches a regexp of

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.