1.GCD 延遲兩秒
dispatch_time_t sleepTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC));
dispatch_after(sleepTime, dispatch_get_main_queue(),^{
//延遲執(zhí)行相關(guān)代碼
});
2.performSelector 延遲兩秒
[self performSelector:@selector(sleepTime) withObject:nil afterDelay:2.0];
3.定時(shí)器 ?
[NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(sleepTime) userInfo:nil repeats:NO];
repeats: 重復(fù)