本文介绍了无法将类型“CFString”的值转换为预期的参数类型“UnsafePointer< Void> (aka'UnsafePointer<()>')的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我遇到构建错误,当我定义行
I am getting a build error, when I define the line
let runFont : CTFontRef = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName)
错误是:无法将类型'CFString'的值转换为预期参数类型' UnsafePointer'(aka'UnsafePointer<()>')
And the error is: Cannot convert value of type 'CFString' to expected argument type 'UnsafePointer' (aka 'UnsafePointer<()>')
推荐答案
尝试
let runFont = unsafeBitCast(CFDictionaryGetValue(CTRunGetAttributes(run), unsafeBitCast(kCTFontAttributeName, UnsafePointer<Void>.self)), CTFontRef.self)
这篇关于无法将类型“CFString”的值转换为预期的参数类型“UnsafePointer< Void> (aka'UnsafePointer<()>')的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!