`save(to:for:completionHandler:)` of `UIDocument` crashes

别来无恙 提交于 2019-12-02 10:41:35

问题


I get crash on every 32 bit device / simulator running iOS 9 on save(to:for:completionHandler:).

Xcode 8.2. Base SDK is 10.2. Target is 9.0. Standard architectures. Swift 3. For both develop and release builds. Sample project.

Could not find if it's known, neither any related issues. Can you recommend any workaround? Should I require 64 bit architecture?


回答1:


The work around is to return NS object, Apple engineer recommended NSMutableData specifically:

override func contents(forType typeName: String) throws -> Any {  
    guard let data = text.data(using: .utf8) else { ... }
    if #available(iOS 10, *) {
        return data
    } else {
        return NSMutableData(data: data)
    }
}


来源:https://stackoverflow.com/questions/41099801/savetoforcompletionhandler-of-uidocument-crashes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!