答案 0 :(得分:4)
为什么使用CFMutableStrings和CFStrings而不是NSSString?
回答你的问题:
CFMutableStringRef mutableString = CFStringCreateMutable(NULL, 0);
if (mutableString) {
CFStringAppend(mutableString, CFSTR("the first part of my string"));
CFStringAppend(mutableString, myString);
}
以下是Apple doc条目:
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