![](/img/trans.png)
[英]Cannot convert value of type 'CMSampleTimingInfo' to expected argument type 'UnsafePointer<CMSampleTimingInfo>'
[英]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.