用惯了GCD就人云亦云的对NSOperation有各种各样的抱怨,但NSOperation也有其独到的优势.
//创建NSInvocationOperation对象,封装操作
NSInvocationOperation *operation1=[[NSInvocationOperation alloc]initWithTarget:self selector:@selector(initAllRoom) object:nil];
_queue=[[NSOperationQueue alloc]init];
//把操作添加到队列中
[_queue addOperation:operation1];
可利用 cancelAllOperations等来进行中止线程操作等.