Warning: UIKit should not be called from a secondary thread

前端 未结 5 1524
悲哀的现实
悲哀的现实 2020-12-10 00:44

In my iPhone app I need to connect to a web server as this can take some time I\'m using threads like this:

[NSThread detachNewThreadSelector:@selector(sendS         


        
5条回答
  •  一个人的身影
    2020-12-10 00:58

    This is indeed unsafe behaviour. The MainThread is the only one that should interface the UI. Have your thread return for instance a string to the mainthread and have a method there update the UI. You can do for instance do this by passing a selector to the other thread method, and then have the other thread call the selector on the mainthread.

提交回复
热议问题