这行代码:
let pkcs12Data = NSData.dataWithContentsOfMappedFile(path!)
在 XCode 7 中显示警告:
'dataWithContentsOfMappedFile' was deprecated in iOS 8.0: Use +dataWithContentsOfURL:options:error: and NSDataReadingMappedIfSafe or NSDataReadingMappedAlways instead.
但是当我尝试任何建议时,我找不到任何响应建议的方法。有什么想法吗?
谢谢...
最佳答案
应该用作 init 方法:
let pkcs12Data = NSData(contentsOfURL: url, options: options, error: &error)
如果您使用的是 swift 2.x,您应该用 try 语句
包装。
关于iOS 已弃用的 dataWithContentsOfMappedFile 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32870855/