- (void)viewDidLoad {
[super viewDidLoad];
// NSThread *thread = [NSThread alloc] initWithTarget:<#(id)#> selector:<#(SEL)#> object:<#(id)#>
// 创建队列
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
// 创建操作
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(download) object:nil];
// [operation start]后直接调用download,是同步执行,在当前线程执行操作
// [operation start];
// 添加操作到队列中,会自动异步执行
[queue addOperation:operation];
// [self download];
}
- (void)download {
NSLog(@"-----download");
}
NSOperation-NSInvocationOperation
最新推荐文章于 2021-06-01 09:49:13 发布