如何在Swift 3中访问CFDictionary? [英] How to access CFDictionary in Swift 3?
本文介绍了如何在Swift 3中访问CFDictionary?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要从CFDictionary
实例读取和写入一些数据(以读取和更新照片中的EXIF数据).为了我的一生,我无法弄清楚如何在Swift 3中做到这一点.我想要的呼叫的签名是:
I need to read and write some data from CFDictionary
instances (to read and update EXIF data in photos). For the life of me, I cannot figure out how to do this in Swift 3. The signature for the call I want is:
func CFDictionaryGetValue(CFDictionary!, UnsafeRawPointer!)
如何将密钥(字符串)转换为UnsafeRawPointer
,以便可以将其传递给此调用?
How the heck do I convert my key (a string) to an UnsafeRawPointer
so I can pass it to this call?
推荐答案
如果您不必处理期望CFDictionary
的其他Core Foundation函数,则可以通过转换为Swift本机Dictionary
来简化它:
If you don't have to deal with other Core Foundation functions expecting an CFDictionary
, you can simplify it by converting to Swift native Dictionary
:
if let dict = cfDict as? [String: AnyObject] {
print(dict["key"])
}
这篇关于如何在Swift 3中访问CFDictionary?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文