Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

usleep() in objective c code

In my objective c code I am using c and c++ libraries. Inside that there is a usleep(20); method used and I am keep on getting a warning "implicit declaration of function 'usleep'". Is it ok to keep this in the code? Can this code chunk can cause to app rejection in App Store?

Thank you.

like image 862
Dilshan Avatar asked Dec 31 '25 09:12

Dilshan


2 Answers

That’s just a compiler warning. You can keep on using the call, just add this to the top of your code:

#import <unistd.h>

As far as App Store goes it’s perfectly safe.

like image 84
zoul Avatar answered Jan 01 '26 21:01

zoul


usleep() is a relative of sleep() and nanosleep(). You can see the pattern; the first takes a parameter in microseconds, the second in seconds, and the third in nanoseconds. Using these methods will put the thread that it was called from to sleep (pause) for the amount of time specified. This is completely legal to use, and I guarantee that your app will not be rejected for its use.

like image 35
Evan Mulawski Avatar answered Jan 01 '26 22:01

Evan Mulawski