繁体   English   中英

无法将&#39;CFString&#39;类型的值转换为预期的参数类型&#39;UnsafePointer <Void> &#39;(又名&#39;UnsafePointer &lt;()&gt;&#39;)

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

当我定义行时,我收到了构建错误

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

错误是:无法将'CFString'类型的值转换为预期的参数类型'UnsafePointer'(又名'UnsafePointer <()>')

尝试

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

Swift 3版@vadian回答:

let runFont = unsafeBitCast(CFDictionaryGetValue(CTRunGetAttributes(run), unsafeBitCast(kCTFontAttributeName, to: UnsafeRawPointer.self)), to: CTFont.self)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM