开发者

call function after defined seconds without using timer

I am calling a function after 180 seconds using timer. But the timer sometimes behaves in different manner and calls the function multiple times in 180 seconds.

please suggest me how to call a function after each 180 seconds untill I post stop message without using timer.

Code

if(!tmr_CallWebService)

{

tmr_CallWebService = [NSTimer scheduledTimerWithTimeInterval:180 target:ClassTracing selector:@selector(startLocationTracing) userInfo:nil rep开发者_高级运维eats:YES];

}

Thanks in advance


I think there is a method to do this task, here use it like this

[self performSelector:@selector(yourMethodName) withObject:[NSArray arrayWithObjects:firstArgument,secondeArgument,nil] afterDelay:180];

use nil in place of array if you have no argument in that method.


You can use - (void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay from NSObject

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜