Search code examples
iosgrand-central-dispatchios11dispatch

Must Dispatch to Main Thread in iOS 11


Prior to iOS 11 I was able to reload a table views data on the fly without having to dispatch the reload to the main thread. However, now that I am testing on a device that has iOS 11 installed it seems I have to dispatch every UI update to the main thread in order for it to work. Or else I end up with empty UI elements. i.e. table views with all the rows but no labels, or buttons with no titles, etc.

Does anyone know what changed in iOS 11 to require this? Is there a way to turn it off?


Solution

  • Since times immemorial Apple has stressed that all interactions with UI elements must happen on the main/GUI thread. Failing to heed that advice would result in weird behavior: sometimes it would work fine, other times it wouldn't. Clearly, now they've changed something to make the behavior more predictable -- it simply doesn't work any more in your specific case and perhaps more generally.

    At any rate, I see no reason why one would not simply do what's spelled out in the documentation and ensure that your UI gets updated from the main thread.