I'm trying to execute a function every second with Objective-c to see if it improve the performance of the application, this is the code.
我试图用Objective-c每秒执行一次函数,看看它是否提高了应用程序的性能,这就是代码。
If I execute the function startTimer from in the init it work and every second runner it's called, if instead I call it from JS it doesn't work. Does someone know how to fix it?
如果我在init中执行函数startTimer并且它被调用的每一个第二个运行程序,如果我从JS调用它它不起作用。有人知道如何解决它吗?
1 个解决方案
#1
0
I found the same issue, however, I found this code that works:
我发现了同样的问题,但是,我发现这个代码有效:
int64_t delayInSeconds = 3.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
// Do Something Here
});
#1
0
I found the same issue, however, I found this code that works:
我发现了同样的问题,但是,我发现这个代码有效:
int64_t delayInSeconds = 3.0;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
// Do Something Here
});