ios - 在 iOS CloudKit 中,是否有办法在数据传输启动后中止/取消?
问题描述
我的 iOS 应用程序在 iCloud Drive 中读取和写入文本和二进制数据。当一个传输完成时,我启动下一个。如果转移在两分钟内没有完成,我会问用户他或她是想再等一会儿还是放弃。众所周知,iCloud 传输有时需要很长时间,或者挂起。
如果用户想放弃,我处理云文档并将其设置为空。之后,用户可以跳转到另一个屏幕。我本来想先中止转移,但不知道该怎么做。
我遇到以下形式的崩溃,我怀疑这可能是相关的(这是在 Xamarin 中,但毫无疑问,这个问题也适用于 Swift/ObjectiveC):
ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x281046140 (type: MyApp_iOS_Cloud_CloudTextDocument). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'MyApp.iOS.Cloud.CloudTextDocument' does not have a constructor that takes one IntPtr argument). Additional information: Selector: contentsForType:error: Method: MyApp.iOS.Cloud.CloudTextDocument:ContentsForType (string,Foundation.NSError&) at (wrapper managed-to-native) ObjCRuntime.Messaging.objc_msgSendSuper(intptr,intptr,intptr,long,intptr) at UIKit.UIDocument.Save (Foundation.NSUrl url, UIKit.UIDocumentSaveOperation saveOperation, UIKit.UIOperationHandler completionHandler)
可能是在我摆脱文档后,传输最终尝试继续,但发现文档已经消失,导致崩溃。
有没有办法中止转移,或者我可以使用其他方法吗?
解决方案
推荐阅读
- ruby - 这个.all有什么原因吗?工作不正常吗?
- c++ - C++ 使用位图的最佳方式
- excel-formula - 根据excel中的键值总结值
- javascript - 新数据推送到数组时更新功能组件
- firebase - 无法使用 FirebaseStore/Flutter 在 UserAccountsDrawerHeader 中返回用户数据
- c++ - 为什么我的 C++ 程序输出 (0.2 / 0.1) = 1 而不是 2?
- python - 通过鼠标指针坐标计算 .tif 图像的真实坐标
- apache - VirtualHost 配置在本地主机上运行
- django - 我想根据用户名创建一个 urlpattern
- django - Django 块翻译无法正常工作