NSInvocationOperation

代码

- (void)viewDidLoad {
    [super viewDidLoad]; // 初始化一个对象,并把操作(相当于GCD里的任务)封装进去 NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(run) object:nil]; // 开始执行 一开始就执行run方法 [operation start]; NSLog(@"怎么才执行我");
}
- (void)run {
    [NSThread sleepForTimeInterval:1.0]; NSLog(@"执行操作%@",[NSThread currentThread]);
}

日志

2016-11-06 08:23:38.999 TTTTTTTTTT[2872:38936] 执行操作<NSThread: x7a710ca0>{
        		

网友评论