#import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; //GCD是纯C的API,而NSOperationQueue操做队列是对象,操做队列在底层是用GCD来实现的 //NSOperatin && NSOperationQueue的好处 /** * 1.取消某个操做,用以代表此任务不须要执行,但启动的任务没法取消 * 2.指定操做间的依赖关系,使特定的操做必须在另一个操做顺利执行完毕后方可执行 * 3.经过键值对机制检测NSOpertion对象的属性 * 4.指定操做优先级,队列以及针对每一个块的。 * 5.能够重写NSOpertion对象 */ NSOperation *option = [[NSOperation alloc]init]; [option start]; [option main]; [option isCancelled]; [option cancel]; //应该尽可能选用高层API,只有在确有必要时才求助于底层。 } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end