简体   繁体   中英

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

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_asyn(dispatch_get_main_queue(), ) { //change UI here } from within a background thread to send your UI actions to the main thread.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM