我有这样的方法:iOS:如何在后台线程中使用数据来努力工作?
- (BOOL)shouldDoSomeWork {
BOOL result = // here I need do hard work with data in background thread and return result, so main thread should wait until the data is calculated and then return result;
return result;
}
如何实现的?
如果你想在后台处理某些东西,你不能像这样返回结果。你将不得不使用委托或块(如匿名函数)。 –
你说你想让主线程在这个新线程上等待。如果这样做,制作线程就没有意义了。就像你在这里使用的方法。 –
这是因为我想开始activityIndicator,然后做一些辛苦的工作。如果要在主线程上努力工作,活动指标不希望可见 – Jim