UIDocument在revertToContentsOfURL:completionHandler:上崩溃,并带有“试图还原尚未打开的文档”

Mar*_*ark 5 ios uidocument

我的iOS应用在生产时崩溃UIDocument.revert(toContentsOf url: URL, completionHandler: ((Bool) -> Void)? = nil)。从错误消息看,好像该文档应该被还原到其自身。例如:

**** Terminating app due to uncaught exception 
     'NSInternalInconsistencyException', 

  reason: 'attempt to revert document at URL (        
    file:///private/var/mobile/Library/Mobile%20Documents/
            iCloud~com~myapp/Documents/sampledocument.test)
    to URL (
    file:///private/var/mobile/Library/Mobile%20Documents/
            iCloud~com~myapp/Documents/sampledocument.test) 
  that is not yet open'
Run Code Online (Sandbox Code Playgroud)

我没有任何特定的代码来还原文档版本,而且我自己也无法重现此版本,但是它对许多用户来说都是这样。

UIDocument会尝试还原其内容,为什么会尝试将同一文件还原为其自身?

这可能是关闭文档但由于某种原因试图放弃更改的竞争条件吗?