swift - 如何在 Swift 3 中访问 CFDictionary?

标签 swift swift3 core-foundation

我需要从 CFDictionary 实例中读取和写入一些数据(以读取和更新照片中的 EXIF 数据)。对于我的生活,我无法弄清楚如何在 Swift 3 中执行此操作。我想要的调用签名是:

func CFDictionaryGetValue(CFDictionary!, UnsafeRawPointer!)

到底如何将我的 key (字符串)转换为 UnsafeRawPointer 以便我可以将其传递给此调用?

最佳答案

如果您不必处理其他需要 CFDictionary 的 Core Foundation 函数,您可以通过转换为 Swift 原生 Dictionary 来简化它:

if let dict = cfDict as? [String: AnyObject] {
    print(dict["key"])
}

关于swift - 如何在 Swift 3 中访问 CFDictionary?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39540829/

相关文章:

ios - swift - "attempt to insert row 0 into section 0, but there are only 0 rows in section 0 after the update"

ios - 屏幕旋转时 ViewController 中的白线

ios - 从国家名称获取 NSLocale

ios - 使用 __bridge 转换 ABPersonCopyImageDataWithFormat 的结果以创建 UIImage 时如何防止对象的潜在泄漏?

c - 将 C 基元值包装在 CFNumbers 的 CFArray 中

ios - Xcode 在单元测试中写入文件

ios - swift segue 不从 tableview 传递数据

Swift:如果我的类中有相同的函数,如何调用非类函数?

ios - 为什么我不能将数字 append 到我的变量?!在 Swift 3 中

c - 尝试让 GetPrimaryMACAddress 停止打印详细信息