Function

CFStringCreateMutableCopy

Creates a mutable copy of a string.

Declaration

CFMutableStringRef CFStringCreateMutableCopy(CFAllocatorRef alloc, CFIndex maxLength, CFStringRef theString);

Parameters

alloc

The allocator to use to allocate memory for the new string. Pass NULL or kCFAllocatorDefault to use the current default allocator.

maxLength

The maximum number of Unicode characters that can be stored by the returned object. Pass 0 if there should be no character limit. Note that initially the returned object still has the same length as the string argument; this parameter simply specifies what the maximum size is. CFString might try to optimize its internal storage by paying attention to this value.

theString

A string to copy.

Return Value

A string that has the same contents as theString. Returns NULL if there was a problem copying the object. Ownership follows the The Create Rule.

Discussion

The returned mutable string is identical to the original string except for (perhaps) the mutability attribute. You can add character data to the returned string with any of the CFStringAppend... functions, and you can insert, delete, replace, pad, and trim characters with the appropriate CFString functions. If the maxLength parameter is greater than 0, any attempt to add characters beyond this limit results in a run-time error.

See Also

CFMutableString Miscellaneous Functions

CFStringAppend

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

CFStringAppendCharacters

Appends a buffer of Unicode characters to the character contents of a CFMutableString object.

CFStringAppendCString

Appends a C string to the character contents of a CFMutableString object.

CFStringAppendFormat

Appends a formatted string to the character contents of a CFMutableString object.

CFStringAppendFormatAndArguments

Appends a formatted string to the character contents of a CFMutableString object.

CFStringAppendPascalString

Appends a Pascal string to the character contents of a CFMutableString object.

CFStringCapitalize

Changes the first character in each word of a string to uppercase (if it is a lowercase alphabetical character).

CFStringCreateMutable

Creates an empty CFMutableString object.

CFStringCreateMutableWithExternalCharactersNoCopy

Creates a CFMutableString object whose Unicode character buffer is controlled externally.

CFStringDelete

Deletes a range of characters in a string.

CFStringFindAndReplace

Replaces all occurrences of a substring within a given range.

CFStringFold

Folds a given string into the form specified by optional flags.

CFStringInsert

Inserts a string at a specified location in the character buffer of a CFMutableString object.

CFStringLowercase

Changes all uppercase alphabetical characters in a CFMutableString to lowercase.

CFStringNormalize

Normalizes the string into the specified form as described in Unicode Technical Report #15.

CFStringPad

Enlarges a string, padding it with specified characters, or truncates the string.

CFStringReplace

Replaces part of the character contents of a CFMutableString object with another string.

CFStringReplaceAll

Replaces all characters of a CFMutableString object with other characters.

CFStringSetExternalCharactersNoCopy

Notifies a CFMutableString object that its external backing store of Unicode characters has changed.

CFStringTransform

Perform in-place transliteration on a mutable string.

CFStringTrim

Trims a specified substring from the beginning and end of a CFMutableString object.

CFStringTrimWhitespace

Trims whitespace from the beginning and end of a CFMutableString object.

CFStringUppercase

Changes all lowercase alphabetical characters in a CFMutableString object to uppercase.