UIDocument的`save(to:for:completionHandler:)`崩溃 [英] `save(to:for:completionHandler:)` of `UIDocument` crashes

查看:79
本文介绍了UIDocument的`save(to:for:completionHandler:)`崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

save(to:for:completionHandler:)上运行iOS 9的每32位设备/模拟器上,我都会崩溃.

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

Xcode 8.2.基本SDK是10.2.目标是9.0.标准架构. Swift3.用于开发和发布版本. 示例项目.

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

找不到,也没有任何相关问题.您能推荐任何解决方法吗?我需要64位体系结构吗?

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

推荐答案

解决方法是返回NS对象,Apple工程师特别推荐NSMutableData:

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)
    }
}

这篇关于UIDocument的`save(to:for:completionHandler:)`崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆