简体   繁体   English

尝试获取Documents文件夹URL的BAD_ACCESS异常

[英]BAD_ACCESS exception trying to get the Documents folder URL

I have weird issue with core data and iOS9 (9.3). 我对核心数据和iOS9(9.3)感到奇怪。 This call throws BAD_ACCESS on iOS9: 此调用在iOS9上引发BAD_ACCESS:

let documents = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)

It works nice on iOS 10, but crashes on iOS 9. 它在iOS 10上运行良好,但在iOS 9上崩溃。

I was digging more and found that even if I call this, app crashes: 我进行了更多的挖掘,发现即使我这样称呼,应用程序也会崩溃:

print(FileManager.SearchPathDirectory.documentDirectory)

What am I missing? 我想念什么? Some config somewhere? 一些地方的配置? I tried it on completely new project and on both device/emulator. 我在全新项目和设备/仿真器上都尝试过。 I temporarily solved it by bridging it from Objective-C, but that is not right solution. 我暂时通过从Objective-C桥接它来解决它,但这不是正确的解决方案。

尝试这个

let documents = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]

So problem was here: https://github.com/apple/swift/pull/5055 所以问题就在这里: https : //github.com/apple/swift/pull/5055

Waiting for new xcode. 等待新的xcode。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM