According to the documentation, CFDictionaryCreate used to instantiate a CFDictionary in swift .
func CFDictionaryCreate(_ allocator: CFAllocator!, _ keys: UnsafeMutablePointer<UnsafePointer<Void>>, _ values: UnsafeMutablePointer<UnsafePointer<Void>>, _ numValues: CFIndex, _ keyCallBacks: UnsafePointer<CFDictionaryKeyCallBacks>, _ valueCallBacks: UnsafePointer<CFDictionaryValueCallBacks>) -> CFDictionary!
How to create keys and values arguments? So far, I have been trying to use swift String , hoping that it will be automatically converted to the appropriate types:
import Foundation var keys : [String] = ["key1", "key2"] var values : [String] = ["value1", "value2"] var keyCallbacks = kCFTypeDictionaryKeyCallBacks var valueCallbacks = kCFTypeDictionaryValueCallBacks var dict : CFDictionary = CFDictionaryCreate(kCFAllocatorDefault, &keys, &values, 2, &keyCallbacks, &valueCallbacks)
Unfortunately, I get an error: String not the correct type for the elements of the keys and values array:
main.swift:41:2: error: 'String' is not identical to 'UnsafePointer<Void>' &configKeys, &configValues, 3, &keyCallbacks, &valueCallbacks)
How do I make UnsafePointer<Void> from String ?