如何解决在 iOS CloudKit 中,有没有办法在数据传输启动后中止/取消数据传输?
我的 iOS 应用读取文本和二进制数据并将其写入 iCloud Drive。当一个传输完成时,我启动下一个。如果传输在两分钟内没有完成,我会问用户他或她是想再等一会儿还是放弃。我们知道,iCloud 传输有时需要很长时间,或者挂起。
如果用户想放弃,我把云文档处理掉,设置为null。之后,用户可以跳转到另一个屏幕。我本来想先中止转移,但不知道该怎么做。
我遇到以下形式的崩溃,我怀疑这可能与此有关(这是在 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,long,intptr) at UIKit.UIDocument.Save (Foundation.NSUrl url,UIKit.UIDocumentSaveOperation saveOperation,UIKit.UIOperationHandler completionHandler)
可能是我删除了文档后,传输最终试图继续,但发现文档已经消失,导致崩溃。
有没有办法中止传输,或者有没有我可以使用的替代方法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。