I have to use CFDictionaryCreate method in Swift(documentation link).
I am having a hard time to initialize the input parameters correctly in order to pass parameters(keys and values) of type UnsafeMutablePointer<UnsafePointer<Void>>.
Here is my code:
var font_name: CFStringRef! = CFStringCreateWithCString(nil, "Courier", kCFStringEncodingASCII) var font: CTFontRef! = CTFontCreateWithName(font_name, 25.0, nil) var keys: [UnsafePointer<Void>] = ???? // how to intialize with "kCTFontAttributeName" var values: [UnsafePointer<Void>] = ???? // how to intialize with "font" variable var keyCallBacks = kCFTypeDictionaryKeyCallBacks var valueCallBacks = kCFTypeDictionaryValueCallBacks var font_attributes: CFDictionaryRef! = CFDictionaryCreate(kCFAllocatorDefault, &keys, &values, sizeofValue(keys), &keyCallBacks, &valueCallBacks) var attr_string: CFAttributedStringRef! = CFAttributedStringCreate(nil, "hello", font_attributes)
[NSString : AnyObject]dictionary is automatically bridged toNSDictionary(and vice versa), andNSDictionaryis toll-free bridged withCFDictionary. – Perhaps you should show your concrete case.font_attributesdictionary for?