Objective-C class time delay?

I was wondering if anyone knows of a class in objective-C that stops / delays the application at a specific time interval at runtime? I already looked at Time Manager and NSTimer and don’t see how I could delay it there. I have never used these two classes before, so maybe someone else can give me advice? Thanks!

+3
source share
3 answers

It really depends on what you mean by “stops / delays the application”. If you have a single-threaded application, you can simply use any of the various sleep calls (sleep, sleep, apply, etc.). This is probably not what you want, because it will simply cause the user interface to freeze for the user and not stop the background threads.

To give a decent answer, you probably need to know what you are actually trying to do. You were waiting for something, polled a resource, etc.

+4
source
#include <unistd.h>
sleep(3); // or usleep(3000000);
+4
source

, [NSThread sleepForTimeInterval:] . , . NSThread , .

+2

Source: https://habr.com/ru/post/1711461/


All Articles