Contents

CFNetServiceCreateTXTDataWithDictionary(_:_:)

Flattens a set of key/value pairs into a CFDataRef suitable for passing to Cfnetservicesettxtdata(_:_:).

Declaration

func CFNetServiceCreateTXTDataWithDictionary(_ alloc: CFAllocator?, _ keyValuePairs: CFDictionary) -> Unmanaged<CFData>?

Parameters

  • alloc:

    The allocator to use to allocate memory for the new object. Pass NULL or Kcfallocatordefault to use the current default allocator.

  • keyValuePairs:

    CFDictionaryRef containing the key/value pairs that are to be placed in a TXT record. Each key must be a CFStringRef and each value should be a CFDataRef or a CFStringRef. (See the discussion below for additional information about values that are CFStringRefs.) This function fails if any other data types are provided. The length of a key and its value should not exceed 255 bytes.

Return Value

A CFData object containing the flattened form of keyValuePairs, or NULL if the dictionary could not be flattened. Ownership follows the The Create Rule.

Discussion

This function flattens the key/value pairs in the dictionary specified by keyValuePairs into a CFDataRef suitable for passing to CFNetServiceSetTXTData(_:_:). Note that this function is not a general purpose function for flattening CFDictionaryRefs.

The keys in the dictionary referenced by keyValuePairs must be CFStringRefs and the values must be CFDataRefs. Any values that are CFStringRefs are converted to CFDataRefs representing the flattened UTF-8 bytes of the string. The types of the values are not encoded in the CFDataRefs, so any CFStringRefs that are converted to CFDataRefs remain CFDataRefs when the CFDataRef produced by this function is processed by CFNetServiceCreateDictionaryWithTXTData(_:_:).

Special Considerations

This function is thread safe.

See Also

Network Services