#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