NSInvocationOperation
代碼
- (void)viewDidLoad {
[super viewDidLoad]; // 初始化一個(gè)對(duì)象,并把操作(相當(dāng)于GCD里的任務(wù))封裝進(jìn)去 NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(run) object:nil]; // 開始執(zhí)行 一開始就執(zhí)行run方法 [operation start]; NSLog(@"怎么才執(zhí)行我");
}
- (void)run {
[NSThread sleepForTimeInterval:1.0]; NSLog(@"執(zhí)行操作%@",[NSThread currentThread]);
}
日志
2016-11-06 08:23:38.999 TTTTTTTTTT[2872:38936] 執(zhí)行操作<NSThread: x7a710ca0>{
網(wǎng)友評(píng)論