The easiest way to create immutable CFString objects is to use the
CFSTR
macro. The argument of the macro must be a constant compile-time string (that is, text enclosed in quotation marks) that contains only ASCII characters; the macro returns a reference to a CFString object.
CFStringRef hello = CFSTR("Hello, world.");
If there are two or more exact instances of a constant string in an executable, only one is stored. A common use of the
CFSTR
macro is in the creation of formatted strings (see Creating String Objects From Formatted Strings for more information). You should not release objects created with the
CFSTR
macro.