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