Slow closing of UIDocument
-
12-12-2019 - |
Question
I have an application with my UIDocument subclass. But the problem is that from time to time method closeWithCompletionHandler
works too long. I even can't wait until the end, it takes too much time. The thing is when I put a breakpoint in - (id)contentsForType:(NSString *)typeName error:(NSError **)outError
method, everything works fine. So, the question is what can cause such effect?
Thanks!
Solution
Is this code running on the main thread? If that's the case, try running it in a background thread using a dispatch queue.
Note that the main thread powers the UI drawing as well, which is why your app gets stuck when the main thread has too much work to do. Therefore, it is always advisable to put larger operations into a background thread.