IOS学习笔记23—多线程之NSThread、NSOperation、NSInvocationOperation
//创建操作队列 NSOperationQueue *operationQueue = [[NSOperationQueue alloc] init]; //设置队列中最大的操作数 [operationQueue setMaxConcurrentOperationCount:1]; //创建操作(最后的object参数是传递给selector方法的参数) NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(doInBackgroud) object:nil]; //将操作添加到操作队列 [operationQueue addOperation:operation]; [operation release]; [operationQueue release];
运行输出结果跟上面的一样。
欢迎关注我的新浪微博和我交流:@唐韧_Ryan