NSOperationQueue mainQueue vs performSelectorOnMainThread?

独自空忆成欢 提交于 2019-12-02 19:01:21
Mike Z
[self performSelectorOnMainThread:@selector(doSomething:) 
                       withObject:object 
                    waitUntilDone:NO]

Will perform the selector right when it is called. This is what you have to use if you want to affect the UI from a background thread. If you say YES to waitUntilDone it will block the thread until the method has completed.

mainQueue adds that block to the operation queue of the mainthread but does not guarantee when it will be executed. There could be other items in that queue still waiting to execute.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!