sleep (int) is a method from a unix system that runs mac. Known as Darwin.
Here is the manpage for sleep
Essentially, this is a C call that allows you to tell the computer about sleep mode for "int" the number of seconds.
Alternatively, you can use "usleep (unsigned int)", which will sleep for "unsigned int" the number of "microseconds", which is the second * 1000 * 1000 or 1000 milliseconds.
Here is ManPage for firmware
Both of these functions are wrapped to access the basic "C / C ++" methods that a typical C / C ++ developer will use.
here is an example of equivalent code
NSTimeInterval sleepTime = 2.0; //Time interval is a double containing fractions of seconds [NSThread sleepForTimeInterval:sleepTime]; // This will sleep for 2 seconds sleep((int)sleepTime); // This will also sleep for 2 seconds
if you want more granularity, you will need usleep (unsigned int), which will give you a much more accurate number.
NSTimeInterval sleepTime = 0.2;
I hope this helps
The lazy coder
source share