作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
这行代码:
let pkcs12Data = NSData.dataWithContentsOfMappedFile(path!)
在 XCode 7 中显示警告:
'dataWithContentsOfMappedFile' was deprecated in iOS 8.0: Use +dataWithContentsOfURL:options:error: and NSDataReadingMappedIfSafe or NSDataReadingMappedAlways instead.
但是当我尝试任何建议时,我找不到任何响应建议的方法。有什么想法吗?
谢谢...
最佳答案
应该用作初始化方法:
let pkcs12Data = NSData(contentsOfURL: url, options: options, error: &error)
如果你使用的是 swift 2.x,你应该用 try-statement
包裹起来。
关于iOS 弃用的 dataWithContentsOfMappedFile 替换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32870855/
这行代码: let pkcs12Data = NSData.dataWithContentsOfMappedFile(path!) 在 XCode 7 中显示警告: 'dataWithContents
我的项目中有以下代码: id mappedData = [dataWithContentsOfMappedFile: path] 显然,如果mappedData 为零,则不会成功。但我怎样才能获得为什
所以 +(id)dataWithContentsOfMappedFile:(NSString *)path自 iOS 5.0 以来显然已弃用。在我看来我应该避免使用它,但我应该使用什么来代替? 我使用
每当我尝试输入 NSData.dataWithContentsOfURL() ,Xcode 无法识别它。它唯一识别的是 NSData.dataWithContentsOfMappedFile() 这是
我使用以下代码从 JSON 文件中检索数据。 let jsonData = try NSData.dataWithContentsOfMappedFile("/Users/User/Desktop/E
我是一名优秀的程序员,十分优秀!