Contents

CFStringGetCharactersPtr(_:)

Quickly obtains a pointer to the contents of a string as a buffer of Unicode characters.

Declaration

func CFStringGetCharactersPtr(_ theString: CFString!) -> UnsafePointer<UniChar>!

Parameters

  • theString:

    The string whose contents you wish to access.

Return Value

A pointer to a buffer of Unicode character, or NULL if the internal storage of theString does not allow this to be returned efficiently.

Discussion

This function either returns the requested pointer immediately, with no memory allocations and no copying, or it returns NULL. If the latter is the result, call an alternative function such as CFStringGetCharacters(_:_:_:) function to extract the characters.

Whether or not this function returns a valid pointer or NULL depends on many factors, all of which depend on how the string was created and its properties. In addition, the function result might change between different releases and on different platforms. So do not count on receiving a non-NULL result from this function under any circumstances (except when the object is created with CFStringCreateMutableWithExternalCharactersNoCopy(_:_:_:_:_:)).

See Also

Accessing Characters