mah*_*udz 5

为什么使用 CFMutableStrings 和 CFStrings 而不是 NSSString?

回答你的问题:

    CFMutableStringRef mutableString = CFStringCreateMutable(NULL, 0);

    if (mutableString) {

            CFStringAppend(mutableString, CFSTR("the first part of my string"));
            CFStringAppend(mutableString, myString);

     }
Run Code Online (Sandbox Code Playgroud)

这是 Apple 文档条目:

CFStringAppend
Appends the characters of a string to those of a CFMutableString object.

void CFStringAppend (
   CFMutableStringRef theString,
   CFStringRef appendedString
);
Parameters
theString
The string to which appendedString is appended. If theString is not a CFMutableString object, an assertion is raised.

appendedString
The string to append.

Discussion
This function reallocates the backing store of theString to accommodate the new length.

Availability
Available in iPhone OS 2.0 and later.
Declared In
CFString.h
Run Code Online (Sandbox Code Playgroud)