When opening UIDocuments from a closed state, I understand that it is it done on another thread. My question is, if I have code on my main thread that will access the document (like performing a fetch request), how is it guaranteed that the document will be open before I try to access it if the opening of the closed document is done asynchronously?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
- Attempt to present UIAlertController on View Contr
You should use
documentState
property ofUIDocument
class. For more detail refer this document documentState description.It returns following enumerators to check:
From Description:
UIDocumentStateNormal
is what you want, as:The document is open, editing is enabled, and there are no conflicts or errors associated with it.
Instead of trying to block a thread, block your application's user from accessing the document until it is open. That's what the completion handler is for.
When the completion handler is invoked simply dismiss whatever temporary user interface you display while the document is opening. This way no threads are blocked while the document is opening, and the application remains responsive (albeit useless).