无法将types'CFString'的值转换为期望的参数types'UnsafePointer <Void>'(又名'UnsafePointer <()>')
当我定义行时,出现构build错误
let runFont : CTFontRef = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName)
错误是:无法将types'CFString'的值转换为期望的参数types'UnsafePointer'(又名'UnsafePointer <()>')
尝试
let runFont = unsafeBitCast(CFDictionaryGetValue(CTRunGetAttributes(run), unsafeBitCast(kCTFontAttributeName, UnsafePointer<Void>.self)), CTFontRef.self)
@vadian Swift 3版本的答案:
let runFont = unsafeBitCast(CFDictionaryGetValue(CTRunGetAttributes(run), unsafeBitCast(kCTFontAttributeName, to: UnsafeRawPointer.self)), to: CTFont.self)