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

时间:2016-03-30 13:26:19

标签: ios swift cocoa core-text quartz-core

我在定义行

时遇到构建错误
 let runFont : CTFontRef = CFDictionaryGetValue(CTRunGetAttributes(run), kCTFontAttributeName)

错误是:无法转换类型&#39; CFString&#39;的值预期参数类型&#39; UnsafePointer&#39; (又名&#39; UnsafePointer&lt;()&gt;&#39;)

2 个答案:

答案 0 :(得分:5)

尝试

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

答案 1 :(得分:2)

Swift 3版@vadian回答:

cat file1.json | jq '.[] | select(.file_name | contains("197407"))'