当我尝试将新创建的 UIManagedDocument 保存到 iCloud 并且网络关闭(例如飞行模式)时,我收到以下错误并崩溃(删除了十六进制代码和不可读的内容):
-[PFUbiquitySafeSaveFile waitForFileToUpload:](272): CoreData: Ubiquity: <PFUbiquityPeerReceipt: ...>(0)
permanentLocation: <PFUbiquityLocation: ...>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~domain~AppName/TransactionLog/mobile.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/DocumentName/XXXXXXXXXXXXXXX/receipt.0.cdt
safeLocation: <PFUbiquityLocation: ...>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~domain~AppName/TransactionLog/mobile.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/DocumentName/XXXXXXXXXXXXXXX/mobile.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.0.cdt
currentLocation: <PFUbiquityLocation: ...>: /private/var/mobile/Library/Mobile Documents/XXXXXXXXXX~com~domain~AppName/TransactionLog/mobile.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/DocumentName/XXXXXXXXXXXXXXX/mobile.XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.0.cdt
kv: (null)
Safe save failed for file, error: Error Domain=NSCocoaErrorDomain Code=512 "The file upload timed out." UserInfo=... {NSLocalizedDescription=The file upload timed out.}
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'This NSPersistentStoreCoordinator has no persistent stores. It cannot perform a save operation.'
*** First throw call stack:
(...)
libc++abi.dylib: terminate called throwing an exception
我不知道这个错误,但它表示无法保存文档,因为无法上传(当然,因为没有网络)。但我不明白为什么我不能用保存完成处理程序捕捉到这个错误:
[theDocumentToSave saveToURL:theDocumentToSave.fileURL
forSaveOperation:UIDocumentSaveForCreating
completionHandler:^(BOOL success) {
if (success) {
// Do somethings, go on, ...
} else {
// Catch error HERE, but this is never called!
}
}];