/*
第一個參數:目標對象 self
第二個參數:方法選擇器 調用的方法
第三個參數:前面調用方法需要傳遞的參數 nil
*/
// (第一種方法)1.創建線程
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(ran:) object:@"ABC"];
// 2.啟動線程
[thread start];
// (第二種方法)
[NSThread detachNewThreadSelector:@selector(ran:) toTarget:self withObject:@"分離子線程"];
// (第三種方法)
[self performSelectorInBackground:@selector(ran:) withObject:@"開啟后臺線程"];
線程間通信--png
[self.imageView performSelectorOnMainThread:@selector(setImage:) withObject:image waitUntilDone:YES];
// 計算一段代碼的耗時時間
NSDate *start = [NSDate date]; // 獲得當前的時間
NSDate *end = [NSDate date];
NSLog(@"%f", [end timeIntervalSinceDate:start]);
CFTimeInterval start = CFAbsoluteTimeGetCurrent();
CFTimeInterval end = CFAbsoluteTimeGetCurrent();
NSLog(@"%f", end - start);