這是我的代碼看起來像現在,我想調用以串行方式這些方法:從後臺線程執行的其他方法執行主線程上的方法?
-(void) methodOnBackThread // this method will run on a background thread
{
[runner runThisMethod]; // and this will run on the same background thread as well
[runner runThisOtherMethod]; // and so will this one
// but I want this one to run on the main thread :
[runner runThisMethodOnTheMainThreadUsing:thisParameter using:thisOtherParamater andUsing:thisOtherOneAsWell];
[runner runThisOtherMethod]; // this one will run on the background thread as well
// but I want this one to run on the main thread :
[runner runThisMethodOnTheMainThreadUsing:thisParameter using:thisOtherParamater andUsing:thisOtherOneAsWell];
[runner runThisOtherMethod]; // this one will run on the background thread as well
// etc..
}
我相信我有使用dispatch_get_main_queue
但我無法弄清楚如何實施這個上述情況。
我如何提交[runner runThisMethodOnTheMainThreadUsing:thisParameter using:thisOtherParamater andUsing:thisOtherOneAsWell];
主線程,然後返回到我的背景,方法,其餘的執行,然後再拿到主線程如果線下一種方法需要它?
的可能重複[確保功能在主線程上運行僅](http://stackoverflow.com/questions/7852737/make-sure-function-runs-on-main-thread-only) –