0x6d6e
0x6d6e

Reputation: 153

Updating UI From a background thread on iOS

On iOS, its well documented that the UI should never be updated from a background thread. Rather the main thread should be the sole interface to update the UI. My Question is why?

Is it because UIControls are not thread safe and hence there is always the possibility of main thread updating the particular control whilst its being tinkered with in a background thread? Is my understanding right?

Thanks

Upvotes: 0

Views: 587

Answers (1)

timelincoln
timelincoln

Reputation: 98

I think it has more to do with keeping the UI responsive, so iOS just prevents you from putting UI stuff in threads that aren't main.

You know you can use dispatch_async(dispatch_get_main_queue(), ) { //change UI here } from within a background thread to send your UI actions to the main thread.

Upvotes: 2

Related Questions