我想知道怎么在main thread号公路上拨打我的function
.
我怎样才能确保我的function
在main thread号公路上被叫醒呢?
(this follows a previous 100 of mine).
我想知道怎么在main thread号公路上拨打我的function
.
我怎样才能确保我的function
在main thread号公路上被叫醒呢?
(this follows a previous 100 of mine).
我可以遵循什么规则来确保我的应用程序只在主线程中执行我自己的代码?
通常你不需要做任何事情来确保这一点——你的 list 通常就足够了.除非你正在与某个API交互,而该API恰好生成了一个线程并在后台运行你的代码,否则你将在主线程上运行.
如果你真的想确定,你可以这样做
[self performSelectorOnMainThread:@selector(myMethod:) withObject:anObj waitUntilDone:YES];
在主线程上执行方法.(还有相当于GCD的课程.)