How to make thread sleep for seconds in iOS?

后端 未结 5 1977
予麋鹿
予麋鹿 2021-02-04 19:39

In iOS env, is it possible to make current thread sleep for seconds, then execute my code? NSTimer, GDC or any technique is okay for me.

5条回答
  •  别跟我提以往
    2021-02-04 19:50

    Use the class method + (void)sleepForTimeInterval:(NSTimeInterval)ti

    The variable NSTimeInterval is of type double and represents the number of seconds to sleep

    // Block for .5 seconds
    [NSThread sleepForTimeInterval:.5];
    

提交回复
热议问题