What's the equivalent of Java's Thread.sleep() in Objective-C/Cocoa?

后端 未结 6 439
野的像风
野的像风 2020-12-23 15:45

In Java you can suspend the current thread\'s execution for an amount of time using Thread.sleep(). Is there something like this in Objective-C?

6条回答
  •  抹茶落季
    2020-12-23 16:23

    Sleeping for one second in Java:

    Thread.sleep(1000);
    

    Sleeping for one second in Objective C:

    [NSThread sleepForTimeInterval:1.0f];
    

提交回复
热议问题