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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:31:41+00:00 2026-06-10T01:31:41+00:00

I have noticed from the llvm source code that the compiler supports the flag:

  • 0

I have noticed from the llvm source code that the compiler supports the flag:

-fconstant-string-class=CLASSNAME

If this flag is not present, the compiler appears to default to NSConstantString.

Upon inspection of Apple’s Foundation Library, NSConstantString inherits from NSSimpleCString which provides the required ivars to enable ObjC Constant String behaviour. This in turn is a child class of NSString.

However, in normal ObjC code, the following is perfectly legal:

NSString *anNSString = @"This is an NSConstantString?";

This seems fine (NSConstantString is the child class), except:

1) The data of a constant string should be funnelled into the ivars declared in NSSimpleCString, which are not available to an NSString.

2) NSString’s iteration methods suggest it is built on arrays of unichars. This means there must be some conversion from NSConstantString’s chars to NSString’s unichars.

As operator overloading is not possible in Objective C, how/where could this conversion take place? Is there some code generation trickery going on here? Or have I missed something more obvious?

  • 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-10T01:31:43+00:00Added an answer on June 10, 2026 at 1:31 am

    This is not the only place in the framework you’ll find that the class you’re dealing with is not the class you’re expecting. As Objective-C is duck-typed, there doesn’t even need to be an inheritance relationship between the classes (although this would be desirable to let isKindOfClass: work correctly).

    The practice of using a “front class” as an interface and a bunch of “private classes” for the implementation is elevated to a pattern in the Cocoa framework. This concept is called a “class cluster”, and most Foundation classes have their own cluster. Since they all share the same public interface, everything works just like you would expect. As far as those are concerned, the front classes themselves should probably be considered abstract (even though the compile-time concept of an abstract class doesn’t exist in Objective-C).

    For instance, both NSArray and NSMutableArray become NSCFArray once you hit the run button. Another case of blatant duck typing: last time I checked, when you call a method that deals with paths on a NSString (for example stringByAppendingPathComponent:), you get an instance of the NSPathStore2 class, even though the documentation says it returns a NSString.

    I don’t see how NSConstantString‘s ivars could be of matter to NSString so long as all relevant methods are implemented/overridden in NSConstantString. As for the conversion itself, there aren’t that many public access points to unichars: by my count, only 5 NSString methods use unichars, so any required conversion could easily be done there.

    EDIT I went a little deeper and found out NSString declares no ivar, leaving absolute discretion to its subclasses as far as storage is concerned. NSSimpleCString declares char* bytes and int numBytes; NSConstantString adds no ivar. Both classes implement/override unichar access methods.

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

Sidebar

Related Questions

I have noticed from several web pages that apparently Spring 3.0 supports @Inject from
From this previously asked question , I have noticed that when I move a
So we are migrating from Informix to Sql Server. And I have noticed that
I have noticed a number of kernel sources that look like this (found randomly
I have noticed that it is possible to define a custom class and then
I have been using php from some time and I have noticed that it
Some Background I have noticed that setting the EditTemplate of a DataForm (from the
I have noticed that some mails come with the from address like : Adam
I have noticed that some apps have a distinction between 'Invites from friends' vs
I have noticed that, from Google Maps page, you can get an embed link

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.