iOS Make sure documents are open before accessing

后端 未结 2 1877
天命终不由人
天命终不由人 2021-01-28 17:19

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 (

2条回答
  •  心在旅途
    2021-01-28 17:24

    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.

    - (void)openWithCompletionHandler:(void (^)(BOOL success))completionHandler
    

    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).

提交回复
热议问题