How to pause objective-c for less than a second

I am writing an application in Xcode 5.1.1 and objective-c . I want to pause the program for 0.1 seconds. To pause a program, I usually use something like this:

sleep(1);

      

But "sleep" only accepts an integer.

The question is: is there a sleep equivalent that floats can take?

+3
floating-point integer objective-c sleep


source to share


1 answer


Use the following code. Convert your time to microseconds.

usleep(10000); //Sleep Time 0.1 seconds
usleep(1000000);//Sleep Time 1 second.

      

or



[NSThread sleepForTimeInterval:0.1f];

      

Regards, Amit

+4


source to share







All Articles
Loading...
X
Show
Funny
Dev
Pics