CFStringReplaceHeader: CFString.h

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

void CFStringReplace (
    CFMutableStringRef theString, 
    CFRange range, 
    CFStringRef replacement
);
theString

Pass a reference to the mutable CFString object with characters that need to be replaced. The function raises an assertion if the CFString object is not mutable.

range

Pass a structure of type CFRange that specifies the range of characters in the mutable CFString object to replace.

replacement

Pass a reference to a CFString object containing the characters that are to replace the range of characters specified by the first two parameters.

DISCUSSION

The CFStringReplace function substitutes a string (represented by a CFString object) for a given range of characters in a mutable CFString object. The characters in the modified object are adjusted left or right (depending on the length of the substituted string) and the character buffer of the object is resized accordingly. Although you can use this function to replace all characters in the mutable CFString (by specifying a range of (0, CFStringGetLenth(theString))), it is more convenient to use the CFStringReplaceAll function for this purpose.


© 1999 Apple Computer, Inc. — (Last Updated 9/15/99)