To increment the retention count of a Core Foundation object, pass a reference to that object as the parameter of the
CFRetain
function:
/* myString is a CFStringRef received from elsewhere */ myString = (CFStringRef)CFRetain(myString);
To decrement the retention count of a Core Foundation object, pass a reference to that object as the parameter of the
CFRelease
function:
CFRelease(myString);
If you want to know the current retention count of a Core Foundation object, pass a reference to that object as the parameter of the
CFGetRetainCount
function:
CFIndex count = CFGetRetainCount(myString);
For more information on reference counting, see in the chapter. Also read subsequent sections in that chapter for guidance on when and how to use the
CFRetain
and
CFRelease
functions.