NSOperation-NSInvocationOperation

来源:互联网 发布:慕恋的喜欢lofter乐乎 编辑:程序博客网 时间:2024/06/05 06:18
- (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");}

0 0
原创粉丝点击