Search code examples
iosswiftcocoacore-textquartz-core

Cannot convert value of type 'CFString' to expected argument type 'UnsafePointer<Void>' (aka 'UnsafePointer<()>')


I am getting a build error, when I define the line

 let runFont : CTFontRef = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName)

And the error is: Cannot convert value of type 'CFString' to expected argument type 'UnsafePointer' (aka 'UnsafePointer<()>')


Solution

  • Try

    let runFont = unsafeBitCast(CFDictionaryGetValue(CTRunGetAttributes(run), unsafeBitCast(kCTFontAttributeName, UnsafePointer<Void>.self)), CTFontRef.self)