用慣了GCD就人云亦云的對NSOperation有各種各樣的抱怨,但NSOperation也有其獨到的優勢.
//創建NSInvocationOperation對象,封裝操作 NSInvocationOperation *operation1=[[NSInvocationOperation alloc]initWithTarget:self selector:@selector(initAllRoom) object:nil]; _queue=[[NSOperationQueue alloc]init]; //把操作添加到隊列中 [_queue addOperation:operation1];可利用 cancelAllOperations等來進行中止線程操作等.
新聞熱點
疑難解答