Search code examples
cocoa-touchuidocument

Exception when calling closeWithCompletionHandler: on a UIDocument more than once


Can a single instance of a UIDocument not be opened and closed multiple times? It seems that I can open, close, and re-open a document, but as soon as I try to call closeWithCompletionHandler: on it a second time I get an exception:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'closeWithCompletionHandler called while document is already closing'

Prior to the call the documentState is Normal.

Hopefully I'm just overlooking something obvious...


Solution

  • Instead of re-opening a closed document with openWithCompletionHandler, create a fresh UIDocument subclass instance and initialize it first with initWithFileURL and then open it.