等待调度队列完成-计时-iPhone
假设我有一个应用程序使用以下方法structure:等待调度队列完成-计时-iPhone,iphone,objective-c,xcode,multithreading,grand-central-dispatch,Iphone,Objective C,Xcode,Multithreading,Grand Central Dispatch,假设我有一个应用程序使用以下方法structure: [self method1]; [self method2]; 方法1包含一个调度队列,例如: [exportSession exportAsynchronouslyWithCompletionHandler:^{ switch (exportSession.status) { case AVAssetExportSessionStatusFailed:{ NSLog (@"FAIL");
[self method1];
[self method2];
方法1包含一个调度队列,例如:
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch (exportSession.status) {
case AVAssetExportSessionStatusFailed:{
NSLog (@"FAIL");
break;
}
case AVAssetExportSessionStatusCompleted: {
NSLog (@"SUCCESS");
}
};
}];
我只想在method1中的调度队列完成后继续执行[method2]。实现这一点的最佳方法是什么?将对
-method2
的调用放在完成处理程序块内。只要method2不在主线程上发生就好了。如果发生了,只需将其分派到完成块内的主队列即可。