Mac Developer Library

Developer

CoreFoundation Framework Reference CFDictionary Reference

Options
Deployment Target:

On This Page
Language:

CFDictionary Reference

CFDictionary and its derived mutable type, CFMutableDictionary Reference, manage associations of key-value pairs. CFDictionary creates static dictionaries where you set the key-value pairs when first creating a dictionary and cannot modify them afterward; CFMutableDictionary creates dynamic dictionaries where you can add or delete key-value pairs at any time, and the dictionary automatically allocates memory as needed.

A key-value pair within a dictionary is called an entry. Each entry consists of one object that represents the key and a second object that is that key’s value. Within a dictionary, the keys are unique. That is, no two keys in a single dictionary are equal (as determined by the equal callback). Internally, a dictionary uses a hash table to organize its storage and to provide rapid access to a value given the corresponding key.

Keys for a CFDictionary may be of any C type, however note that if you want to convert a CFPropertyList to XML, any dictionary’s keys must be CFString objects.

You create static dictionaries using either the CFDictionaryCreate or CFDictionaryCreateCopy function. Key-value pairs are passed as parameters to CFDictionaryCreate. When adding key-value pairs to a dictionary, the keys and values are not copied—they are retained so they are not invalidated before the dictionary is deallocated.

CFDictionary provides functions for querying the values of a dictionary. The function CFDictionaryGetCount returns the number of key-value pairs in a dictionary; the CFDictionaryContainsValue function checks if a value is in a dictionary; and CFDictionaryGetKeysAndValues returns a C array containing all the values and a C array containing all the keys in a dictionary.

The CFDictionaryApplyFunction function lets you apply a function to all key-value pairs in a dictionary.

CFDictionary is “toll-free bridged” with its Cocoa Foundation counterpart, NSDictionary. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an NSDictionary * parameter, you can pass in a CFDictionaryRef, and in a function where you see a CFDictionaryRef parameter, you can pass in an NSDictionary instance. This also applies to concrete subclasses of NSDictionary. See Toll-Free Bridged Types for more information on toll-free bridging.

Functions

  • Creates an immutable dictionary containing the specified key-value pairs.

    Declaration

    Swift

    func CFDictionaryCreate(_ allocator: CFAllocator!, _ keys: UnsafeMutablePointer<UnsafePointer<Void>>, _ values: UnsafeMutablePointer<UnsafePointer<Void>>, _ numValues: CFIndex, _ keyCallBacks: UnsafePointer<CFDictionaryKeyCallBacks>, _ valueCallBacks: UnsafePointer<CFDictionaryValueCallBacks>) -> CFDictionary!

    Objective-C

    CFDictionaryRef CFDictionaryCreate ( CFAllocatorRef allocator, const void **keys, const void **values, CFIndex numValues, const CFDictionaryKeyCallBacks *keyCallBacks, const CFDictionaryValueCallBacks *valueCallBacks );

    Parameters

    allocator

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

    keys

    A C array of the pointer-sized keys to be in the new dictionary. This value may be NULL if the numValues parameter is 0. This C array is not changed or freed by this function. The value must be a valid pointer to a C array of at least numValues pointers.

    values

    A C array of the pointer-sized values to be in the new dictionary. This value may be NULL if the numValues parameter is 0. This C array is not changed or freed by this function. The value must be a valid pointer to a C array of at least numValues elements.

    numValues

    The number of key-value pairs to copy from the keys and values C arrays into the new dictionary. This number will be the count of the dictionary; it must be non-negative and less than or equal to the actual number of keys or values.

    keyCallBacks

    A pointer to a CFDictionaryKeyCallBacks structure initialized with the callbacks to use to retain, release, describe, and compare keys in the dictionary. A copy of the contents of the callbacks structure is made, so that a pointer to a structure on the stack can be passed in or can be reused for multiple collection creations.

    This value may be NULL, which is treated as if a valid structure of version 0 with all fields NULL had been passed in. Otherwise, if any of the fields are not valid pointers to functions of the correct type, or this parameter is not a valid pointer to a CFDictionaryKeyCallBacks structure, the behavior is undefined. If any of the keys put into the collection is not one understood by one of the callback functions the behavior when that callback function is used is undefined.

    If the collection will contain CFType objects only, then pass a pointer to kCFTypeDictionaryKeyCallBacks as this parameter to use the default callback functions.

    valueCallBacks

    A pointer to a CFDictionaryValueCallBacks structure initialized with the callbacks to use to retain, release, describe, and compare values in the dictionary. A copy of the contents of the callbacks structure is made, so that a pointer to a structure on the stack can be passed in or can be reused for multiple collection creations.

    This value may be NULL, which is treated as if a valid structure of version 0 with all fields NULL had been passed in. Otherwise, if any of the fields are not valid pointers to functions of the correct type, or this parameter is not a valid pointer to a CFDictionaryValueCallBacks structure, the behavior is undefined. If any value put into the collection is not one understood by one of the callback functions the behavior when that callback function is used is undefined.

    If the collection will contain CFType objects only, then pass a pointer to kCFTypeDictionaryValueCallBacks as this parameter to use the default callback functions.

    Return Value

    A new dictionary, or NULL if there was a problem creating the object. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns a new immutable dictionary with the key-value pairs of another dictionary.

    Declaration

    Swift

    func CFDictionaryCreateCopy(_ allocator: CFAllocator!, _ theDict: CFDictionary!) -> CFDictionary!

    Objective-C

    CFDictionaryRef CFDictionaryCreateCopy ( CFAllocatorRef allocator, CFDictionaryRef theDict );

    Parameters

    allocator

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

    theDict

    The dictionary to copy. The keys and values from the dictionary are copied as pointers into the new dictionary. However, the keys and values are also retained by the new dictionary. The count of the new dictionary is the same as the count of theDict. The new dictionary uses the same callbacks as theDict.

    Return Value

    A new dictionary that contains the same key-value pairs as theDict, or NULL if there was a problem creating the object. Ownership follows the Create Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns a Boolean value that indicates whether a given key is in a dictionary.

    Declaration

    Swift

    func CFDictionaryContainsKey(_ theDict: CFDictionary!, _ key: UnsafePointer<Void>) -> Boolean

    Objective-C

    Boolean CFDictionaryContainsKey ( CFDictionaryRef theDict, const void *key );

    Parameters

    theDict

    The dictionary to examine.

    key

    The key for which to find matches in theDict. The key hash and equal callbacks provided when the dictionary was created, are used to compare. If the hash callback is NULL, key is treated as a pointer and converted to an integer. If the equal callback is NULL, pointer equality (in C, ==) is used. If key, or any of the keys in the dictionary, is not understood by the equal callback, the behavior is undefined.

    Return Value

    true if key is in the dictionary, otherwise false.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns a Boolean value that indicates whether a given value is in a dictionary.

    Declaration

    Swift

    func CFDictionaryContainsValue(_ theDict: CFDictionary!, _ value: UnsafePointer<Void>) -> Boolean

    Objective-C

    Boolean CFDictionaryContainsValue ( CFDictionaryRef theDict, const void *value );

    Parameters

    theDict

    The dictionary to examine.

    value

    The value for which to find matches in theDict. The value equal callback provided when the dictionary was created is used to compare. If the equal callback was NULL, pointer equality (in C, ==) is used. If value, or any other value in the dictionary, is not understood by the equal callback, the behavior is undefined.

    Return Value

    true if value is in the dictionary, otherwise false.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the number of key-value pairs in a dictionary.

    Declaration

    Swift

    func CFDictionaryGetCount(_ theDict: CFDictionary!) -> CFIndex

    Objective-C

    CFIndex CFDictionaryGetCount ( CFDictionaryRef theDict );

    Parameters

    theDict

    The dictionary to examine.

    Return Value

    The number of number of key-value pairs in theDict.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the number of times a key occurs in a dictionary.

    Declaration

    Swift

    func CFDictionaryGetCountOfKey(_ theDict: CFDictionary!, _ key: UnsafePointer<Void>) -> CFIndex

    Objective-C

    CFIndex CFDictionaryGetCountOfKey ( CFDictionaryRef theDict, const void *key );

    Parameters

    theDict

    The dictionary to examine.

    key

    The key for which to find matches in theDict. The key hash and equal callbacks provided when the dictionary was created are used to compare. If the hash callback was NULL, the key is treated as a pointer and converted to an integer. If the equal callback was NULL, pointer equality (in C, ==) is used. If key, or any of the keys in the dictionary, is not understood by the equal callback, the behavior is undefined.

    Return Value

    Returns 1 if a matching key is used by the dictionary, otherwise 0.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Counts the number of times a given value occurs in the dictionary.

    Declaration

    Swift

    func CFDictionaryGetCountOfValue(_ theDict: CFDictionary!, _ value: UnsafePointer<Void>) -> CFIndex

    Objective-C

    CFIndex CFDictionaryGetCountOfValue ( CFDictionaryRef theDict, const void *value );

    Parameters

    theDict

    The dictionary to examine.

    value

    The value for which to find matches in theDict. The value equal callback provided when the dictionary was created is used to compare. If the equal callback was NULL, pointer equality (in C, ==) is used. If value, or any other value in the dictionary, is not understood by the equal callback, the behavior is undefined.

    Return Value

    The number of times the value occurs in theDict.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Fills two buffers with the keys and values from a dictionary.

    Declaration

    Swift

    func CFDictionaryGetKeysAndValues(_ theDict: CFDictionary!, _ keys: UnsafeMutablePointer<UnsafePointer<Void>>, _ values: UnsafeMutablePointer<UnsafePointer<Void>>)

    Objective-C

    void CFDictionaryGetKeysAndValues ( CFDictionaryRef theDict, const void **keys, const void **values );

    Parameters

    theDict

    The dictionary to examine.

    keys

    A C array of pointer-sized values that, on return, is filled with keys from the theDict. The keys and values C arrays are parallel to each other (that is, the items at the same indices form a key-value pair from the dictionary). This value must be a valid pointer to a C array of the appropriate type and size (that is, a size equal to the count of theDict), or NULL if the keys are not required. If the keys are Core Foundation objects, ownership follows the Get Rule.

    values

    A C array of pointer-sized values that, on return, is filled with values from the theDict. The keys and values C arrays are parallel to each other (that is, the items at the same indices form a key-value pair from the dictionary). This value must be a valid pointer to a C array of the appropriate type and size (that is, a size equal to the count of theDict), or NULL if the values are not required. If the values are Core Foundation objects, ownership follows the Get Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the value associated with a given key.

    Declaration

    Swift

    func CFDictionaryGetValue(_ theDict: CFDictionary!, _ key: UnsafePointer<Void>) -> UnsafePointer<Void>

    Objective-C

    const void * CFDictionaryGetValue ( CFDictionaryRef theDict, const void *key );

    Parameters

    theDict

    The dictionary to examine.

    key

    The key for which to find a match in theDict. The key hash and equal callbacks provided when the dictionary was created are used to compare. If the hash callback was NULL, the key is treated as a pointer and converted to an integer. If the equal callback was NULL, pointer equality (in C, ==) is used. If key, or any of the keys in theDict, is not understood by the equal callback, the behavior is undefined.

    Return Value

    The value associated with key in theDict, or NULL if no key-value pair matching key exists. Since NULL is also a valid value in some dictionaries, use CFDictionaryGetValueIfPresent to distinguish between a value that is not found, and a NULL value. If the value is a Core Foundation object, ownership follows the Get Rule.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns a Boolean value that indicates whether a given value for a given key is in a dictionary, and returns that value indirectly if it exists.

    Declaration

    Swift

    func CFDictionaryGetValueIfPresent(_ theDict: CFDictionary!, _ key: UnsafePointer<Void>, _ value: UnsafeMutablePointer<UnsafePointer<Void>>) -> Boolean

    Objective-C

    Boolean CFDictionaryGetValueIfPresent ( CFDictionaryRef theDict, const void *key, const void **value );

    Parameters

    theDict

    The dictionary to examine.

    key

    The key for which to find a match in theDict. The key hash and equal callbacks provided when the dictionary was created are used to compare. If the hash callback was NULL, key is treated as a pointer and converted to an integer. If the equal callback was NULL, pointer equality (in C, ==) is used. If key, or any of the keys in theDict, is not understood by the equal callback, the behavior is undefined.

    value

    A pointer to memory which, on return, is filled with the pointer-sized value if a matching key is found. If no key match is found, the contents of the storage pointed to by this parameter are undefined. This value may be NULL, in which case the value from the dictionary is not returned (but the return value of this function still indicates whether or not the key-value pair was present). If the value is a Core Foundation object, ownership follows the Get Rule.

    Return Value

    true if a matching key was found, otherwise false.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Calls a function once for each key-value pair in a dictionary.

    Declaration

    Swift

    func CFDictionaryApplyFunction(_ theDict: CFDictionary!, _ applier: CFDictionaryApplierFunction, _ context: UnsafeMutablePointer<Void>)

    Objective-C

    void CFDictionaryApplyFunction ( CFDictionaryRef theDict, CFDictionaryApplierFunction applier, void *context );

    Parameters

    theDict

    The dictionary to operate upon.

    applier

    The callback function to call once for each key-value pair in theDict. If this parameter is not a pointer to a function of the correct prototype, the behavior is undefined. If there are keys or values which the applier function does not expect or cannot properly apply to, the behavior is undefined.

    context

    A pointer-sized program-defined value, which is passed as the third parameter to the applier function, but is otherwise unused by this function. The value must be appropriate for the applier function.

    Discussion

    If this function iterates over a mutable collection, it is unsafe for the applier function to change the contents of the collection.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Returns the type identifier for the CFDictionary opaque type.

    Declaration

    Swift

    func CFDictionaryGetTypeID() -> CFTypeID

    Objective-C

    CFTypeID CFDictionaryGetTypeID ( void );

    Return Value

    The type identifier for the CFDictionary opaque type.

    Discussion

    CFMutableDictionary objects have the same type identifier as CFDictionary objects.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

Callbacks

  • Prototype of a callback function that may be applied to every key-value pair in a dictionary.

    Declaration

    Swift

    typealias CFDictionaryApplierFunction = CFunctionPointer<((UnsafePointer<Void>, UnsafePointer<Void>, UnsafeMutablePointer<Void>) -> Void)>

    Objective-C

    typedef void (*CFDictionaryApplierFunction) ( const void *key, const void *value, void *context );

    Parameters

    key

    The key associated with the current key-value pair.

    value

    The value associated with the current key-value pair.

    context

    The program-defined context parameter given to the apply function.

    Discussion

    This callback is passed to the CFDictionaryApplyFunction function which iterates over the key-value pairs in a dictionary and applies the behavior defined in the applier function to each key-value pair in a dictionary.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Prototype of a callback function used to get a description of a value or key in a dictionary.

    Declaration

    Swift

    typealias CFDictionaryCopyDescriptionCallBack = CFunctionPointer<((UnsafePointer<Void>) -> Unmanaged<CFString>!)>

    Objective-C

    typedef CFStringRef (*CFDictionaryCopyDescriptionCallBack)( const void *value );

    Parameters

    value

    The value to be described.

    Return Value

    A text description of value.

    Discussion

    This callback is passed to CFDictionaryCreate in a CFDictionaryKeyCallBacks structure or CFDictionaryValueCallBacks. This callback is used by the CFCopyDescription function.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Prototype of a callback function used to determine if two values or keys in a dictionary are equal.

    Declaration

    Swift

    typealias CFDictionaryEqualCallBack = CFunctionPointer<((UnsafePointer<Void>, UnsafePointer<Void>) -> Boolean)>

    Objective-C

    typedef Boolean (*CFDictionaryEqualCallBack) ( const void *value1, const void *value2 );

    Parameters

    value1

    A value in the dictionary.

    value2

    Another value in the dictionary.

    Discussion

    This callback is passed to CFDictionaryCreate in a CFDictionaryKeyCallBacks and CFDictionaryValueCallBacks structure.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Prototype of a callback function invoked to compute a hash code for a key. Hash codes are used when key-value pairs are accessed, added, or removed from a collection.

    Declaration

    Swift

    typealias CFDictionaryHashCallBack = CFunctionPointer<((UnsafePointer<Void>) -> CFHashCode)>

    Objective-C

    typedef CFHashCode (*CFDictionaryHashCallBack) ( const void *value );

    Parameters

    value

    The value used to compute the hash code.

    Return Value

    An integer that can be used as a table address in a hash table structure.

    Discussion

    This callback is passed to CFDictionaryCreate in a CFDictionaryKeyCallBacks structure.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Prototype of a callback function used to release a key-value pair before it’s removed from a dictionary.

    Declaration

    Swift

    typealias CFDictionaryReleaseCallBack = CFunctionPointer<((CFAllocator!, UnsafePointer<Void>) -> Void)>

    Objective-C

    typedef void (*CFDictionaryReleaseCallBack) ( CFAllocatorRef allocator, const void *value );

    Parameters

    allocator

    The dictionary’s allocator.

    value

    The value being removed from the dictionary.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • Prototype of a callback function used to retain a value or key being added to a dictionary.

    Declaration

    Swift

    typealias CFDictionaryRetainCallBack = CFunctionPointer<((CFAllocator!, UnsafePointer<Void>) -> UnsafePointer<Void>)>

    Objective-C

    typedef const void *(*CFDictionaryRetainCallBack) ( CFAllocatorRef allocator, const void *value );

    Parameters

    allocator

    The dictionary’s allocator.

    value

    The value being added to the dictionary.

    Return Value

    The value or key to store in the dictionary, which is usually the value parameter passed to this callback, but may be a different value if a different value should be stored in the collection.

    Discussion

    This callback is passed to CFDictionaryCreate in a CFDictionaryKeyCallBacks and CFDictionaryValueCallBacks structure.

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

Data Types

Miscellaneous

  • This structure contains the callbacks used to retain, release, describe, and compare the keys in a dictionary.

    Declaration

    Swift

    struct CFDictionaryKeyCallBacks { var version: CFIndex var retain: CFDictionaryRetainCallBack var release: CFDictionaryReleaseCallBack var copyDescription: CFDictionaryCopyDescriptionCallBack var equal: CFDictionaryEqualCallBack var hash: CFDictionaryHashCallBack }

    Objective-C

    struct CFDictionaryKeyCallBacks { CFIndex version; CFDictionaryRetainCallBack retain; CFDictionaryReleaseCallBack release; CFDictionaryCopyDescriptionCallBack copyDescription; CFDictionaryEqualCallBack equal; CFDictionaryHashCallBack hash; }; typedef struct CFDictionaryKeyCallBacks CFDictionaryKeyCallBacks;

    Fields

    version

    The version number of this structure. If not one of the defined version numbers for this opaque type, the behavior is undefined. The current version of this structure is 0.

    retain

    The callback used to retain each key as they are added to the collection. This callback returns the value to use as the key in the dictionary, which is usually the value parameter passed to this callback, but may be a different value if a different value should be used as the key. If NULL, keys are not retained. See CFDictionaryRetainCallBack for a descriptions of this function’s parameters.

    release

    The callback used to release keys as they are removed from the dictionary. If NULL, keys are not released. See CFDictionaryReleaseCallBack for a description of this callback.

    copyDescription

    The callback used to create a descriptive string representation of each key in the dictionary. If NULL, the collection will create a simple description of each key. See CFDictionaryCopyDescriptionCallBack for a description of this callback.

    equal

    The callback used to compare keys in the dictionary for equality. If NULL, the collection will use pointer equality to compare keys in the collection. See CFDictionaryEqualCallBack for a description of this callback.

    hash

    The callback used to compute a hash code for keys as they are used to access, add, or remove values in the dictionary. If NULL, the collection computes a hash code by converting the pointer value to an integer. See CFDictionaryHashCallBack for a description of this callback.

    Availability

    Available in OS X v10.0 and later.

  • A reference to an immutable dictionary object.

    Declaration

    Swift

    typealias CFDictionaryRef = CFDictionary

    Objective-C

    typedef const struct __CFDictionary *CFDictionaryRef;

    Import Statement

    Objective-C

    @import CoreFoundation;

    Swift

    import CoreFoundation

    Availability

    Available in OS X v10.0 and later.

  • This structure contains the callbacks used to retain, release, describe, and compare the values in a dictionary.

    Declaration

    Swift

    struct CFDictionaryValueCallBacks { var version: CFIndex var retain: CFDictionaryRetainCallBack var release: CFDictionaryReleaseCallBack var copyDescription: CFDictionaryCopyDescriptionCallBack var equal: CFDictionaryEqualCallBack }

    Objective-C

    struct CFDictionaryValueCallBacks { CFIndex version; CFDictionaryRetainCallBack retain; CFDictionaryReleaseCallBack release; CFDictionaryCopyDescriptionCallBack copyDescription; CFDictionaryEqualCallBack equal; }; typedef struct CFDictionaryValueCallBacks CFDictionaryValueCallBacks;

    Fields

    version

    The version number of this structure. If not one of the defined version numbers for this opaque type, the behavior is undefined. The current version of this structure is 0.

    retain

    The callback used to retain each value as they are added to the collection. This callback returns the value to use as the value in the dictionary, which is usually the value parameter passed to this callback, but may be a different value if a different value should be used as the value. If NULL, values are not retained. See CFDictionaryRetainCallBack for a descriptions of this function’s parameters.

    release

    The callback used to release values as they are removed from the dictionary. If NULL, values are not released. See CFDictionaryReleaseCallBack for a description of this callback.

    copyDescription

    The callback used to create a descriptive string representation of each value in the dictionary. If NULL, the collection will create a simple description of each value. See CFDictionaryCopyDescriptionCallBack for a description of this callback.

    equal

    The callback used to compare values in the dictionary for equality. If NULL, the collection will use pointer equality to compare values in the collection. See CFDictionaryEqualCallBack for a description of this callback.

    Availability

    Available in OS X v10.0 and later.

Constants

Miscellaneous

  • CFDictionary provides some predefined callbacks for your convenience.

    Declaration

    Swift

    let kCFCopyStringDictionaryKeyCallBacks: CFDictionaryKeyCallBacks let kCFTypeDictionaryKeyCallBacks: CFDictionaryKeyCallBacks let kCFTypeDictionaryValueCallBacks: CFDictionaryValueCallBacks

    Objective-C

    const CFDictionaryKeyCallBacks kCFCopyStringDictionaryKeyCallBacks; const CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks; const CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;

    Constants

    • kCFCopyStringDictionaryKeyCallBacks

      kCFCopyStringDictionaryKeyCallBacks

      Predefined CFDictionaryKeyCallBacks structure containing a set of callbacks appropriate for use when the keys of a CFDictionary are all CFString objects, which may be mutable and need to be copied in order to serve as constant keys for the values in the dictionary.

      You typically use a pointer to this constant when creating a new dictionary.

      Available in OS X v10.0 and later.

    • kCFTypeDictionaryKeyCallBacks

      kCFTypeDictionaryKeyCallBacks

      Predefined CFDictionaryKeyCallBacks structure containing a set of callbacks appropriate for use when the keys of a CFDictionary are all CFType-derived objects.

      The retain callback is CFRetain, the release callback is CFRelease, the copy callback is CFCopyDescription, the equal callback is CFEqual. Therefore, if you use a pointer to this constant when creating the dictionary, keys are automatically retained when added to the collection, and released when removed from the collection.

      Available in OS X v10.0 and later.

    • kCFTypeDictionaryValueCallBacks

      kCFTypeDictionaryValueCallBacks

      Predefined CFDictionaryValueCallBacks structure containing a set of callbacks appropriate for use when the values in a CFDictionary are all CFType-derived objects.

      The retain callback is CFRetain, the release callback is CFRelease, the copy callback is CFCopyDescription, and the equal callback is CFEqual. Therefore, if you use a pointer to this constant when creating the dictionary, values are automatically retained when added to the collection, and released when removed from the collection.

      Available in OS X v10.0 and later.