方法调度器和进度处理程序。
将"ITActionManager"(以及如果你想使用构建NSInvocation的辅助方法,则"NSInvocation+SimpleCreation")复制到你的项目中,并在需要使用时导入。
#import "ITActionManager.h"
#import "NSInvocation+SimpleCreation.h"
// Invocations
NSInvocation *inv = [ITActionManager invocationWithTarget:yourTarget andSelector:@selector(yourSelector:)];
NSInvocation *inv2 = [ITActionManager invocationWithTarget:yourTarget2 andSelector:@selector(yourSelector2:)];
// Action manager
ITActionManager *actionManager = [[ITActionManager alloc] init];
[actionManager addActionsProgressHandler:^(float percentProgress) {
NSLog(@"Progress - %f", percentProgress);
}];
[actionManager addActionsResultHandler:^(float result) {
NSLog(@"Completed.");
}];
[actionManager performMethods:@[inv, inv2]];
灵感来自Sebastien Windal在使用blocks的回调处理程序上的内容