我有這樣的方法: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