Makes a newly allocated Core Foundation object eligible for collection.
- iOS 2.0+
- macOS 10.5+
- Mac Catalyst 13.0+Beta
- tvOS 9.0+
- watchOS 2.0+
This function is a wrapper for
CFMake, but its return type is
id—avoiding the need for casting when using Cocoa objects.
This function may be useful when returning Core Foundation objects in code that must support both garbage-collected and non-garbage-collected environments, as illustrated in the following example.
CFTypeRef style objects are garbage collected, yet only sometime after the last
CFRelease is performed. Particularly for fully-bridged CFTypeRef objects such as CFStrings and collections (such as CFDictionary), you must call either
CFMake or the more type safe
NSMake, preferably right upon allocation.