ios时间函数

宇文鸿畴
2023-12-01
  1. [self performSelector:@selector(函数名) withObject:nil afterDelay:5.0f]

    条件:在uiviewController的主线程

  2. [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(函数名) userInfo:nil repeats:NO];
    在具体函数中,执行代码,执行完毕以后调用NSTimer invalidate方法来销毁timer

  3. [NSThread sleepForTimeInterval:5.0f];
    [要延迟执行的方法];

    条件:主线程或者子线程都可

 类似资料: