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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:19:42+00:00 2026-05-28T06:19:42+00:00

How can I count the number of different characters used in a NSString. Basically,

  • 0

How can I count the number of different characters used in a NSString.
Basically, from the string

Condimentum Consectetur Cras

I would like to get 14 as an answer because:

Condimet scura

We can’t assume the NSString’s content will always be English; a behaviour similar to [NSString length] for such cases – counting Unicode characters – is, therefore, expected.

  • 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-28T06:19:43+00:00Added an answer on May 28, 2026 at 6:19 am
    NSString *oldString=@"THIS IS OLD STRING.";
    NSMutableArray *charArray=[[[NSMutableArray alloc]init ] autorelease];
    for (int k1=0; k1<[oldString length]; k1++) {
        NSString *ichar  = [NSString stringWithFormat:@"%c", [oldString characterAtIndex:k1]];
        if (![charArray containsObject:ichar]) {
            [charArray addObject:ichar];
        }
    }
    NSMutableString *newString=[[NSMutableString alloc]init]; 
    for (int k2=0; k2<[charArray count]; k2++) {
        NSString *ichar  =[charArray objectAtIndex:k2];
        [newString appendString:ichar];
    }
        NSLog(@"old string lenght is %d",[oldString length]);
    NSLog(@"new string lenght is %d",[newString length]);
    

    Did You try this. I hope it will helps You.

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

Sidebar

Related Questions

I would like to know how I can count the number of unique values
How can I count number of steps between different numbers. I have a method
I have a table and can count the number of rows using var count
In the 10 years I've been programming, I can count the number of data
How can I count the number of elements in an array, because contrary to
How can i count the number of stored procedures in my database and is
How can I count the number of files in a directory using C on
Is there a way I can programmatically count the number of links for a
I can not seem to figure out how to count the number of seconds
I'd like to group and count the number of entries in a table that

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.