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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T10:07:42+00:00 2026-05-12T10:07:42+00:00

There is an NSString method -characterAtIndex: which returns an unichar. (unichar)characterAtIndex:(NSUInteger)index I wonder if

  • 0

There is an NSString method -characterAtIndex: which returns an unichar.

  • (unichar)characterAtIndex:(NSUInteger)index

I wonder if this unichar, which obviously is not an NSString, can be converted into an NSString or feeded to an NSString for comparing purposes?

And: Does an NSString internally just consist of an array of unichar items?

  • 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-12T10:07:42+00:00Added an answer on May 12, 2026 at 10:07 am

    You have two options: the first is a category adding a stringWithUnichar method to NSString:

    @interface NSString (MNNSStringWithUnichar)
    + (NSString *) stringWithUnichar: (unichar) value;
    @end
    
    
    @implementation NSString (MNNSStringWithUnichar)
    
    + (NSString *) stringWithUnichar:(unichar) value {
         NSString *str = [NSString stringWithFormat: @"%C", value];
         return str;
    }
    
    @end
    

    Then call it with

    NSString *otherString = @"TestString";
    
    NSString *str = [NSString stringWithUnichar:[otherString characterAtIndex:1]];
    

    or you could just directly go like this:

    NSString *str = [NSString stringWithFormat:@"%C",[otherString characterAtIndex:1]];
    

    Choose the category if you want to use it repeatedly, or if you only have to do it once, use the stringWithFormat example!!

    Not to sure about the internals of NSString, but I’d guess it is probably wrapping a

    unichar *
    

    or an array of unichars (like a C char *)

    A unichar is simply a 16bit value that is used to store a character. Unlike an unsigned char which is only 8 bits, it can hold more than 0-255, so it can hold unicode characters as well, which are 16bits. A NSString is a (cluster of) class[es] that contains an array of unichars

    EDIT

    Here are a few articles about what people think an NSString is:

    http://cocoawithlove.com/2008/08/string-philosophies-char-arrays.html

    http://www.reddit.com/r/programming/comments/6v1yw/string_philosophies_char_arrays_stdstring_and/

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

Sidebar

Related Questions

Is there an equivalent to NSString's sizeWithFont: method that can be used for calculating
I don't know why this method returns a blank string: - (NSString *)installedGitLocation {
NSLog puts something into stderr, is there a Objective-c method that can put NSString
is there a method to verify if a NSString haven't characters? example of string
I there any specific list for animationID in + (void)beginAnimations:(NSString *)animationID context:(void *)context method
There's a special NSString initWithData method for grabbing bits and converting them into string.
There is the UITextFieldDelegate protocol, which offers only one reasonable method to get notified
I have this method: + (MHTwitterParser*)createParser:(NSString*)format { if ([format compare:@json] == NSOrderedSame) { return
I use this method to access my mysql database from Xcode: NSString *URL =
Does anyone know if there is a method to sort an NSString of ASCII

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.