8.5. Constant String Objects

8.5 Constant String Objects

GNU Objective-C provides constant string objects that are generated directly by the compiler. You declare a constant string object by prefixing a C constant string with the character ‘@’:

id myString = @"this is a constant string object";

The constant string objects are by default instances of the NXConstantString class which is provided by the GNU Objective-C runtime. To get the definition of this class you must include the objc/NXConstStr.h header file.

User defined libraries may want to implement their own constant string class. To be able to support them, the GNU Objective-C compiler provides a new command line options -fconstant-string-class=class-name. The provided class should adhere to a strict structure, the same as NXConstantString’s str