Ehsan Kayani
Ehsan Kayani

Reputation: 11

how to remove timer

i have this timer

[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimerFunc) userInfo:nil repeats:YES];

and on some function i want to completly remove this...how?

Upvotes: 0

Views: 1196

Answers (1)

Mikael
Mikael

Reputation: 3612

You should not use NSTimer in Cocos2d, instead you should do:

[self schedule:@selector(updateTimerFunc) interval:1.0];

And to remove it:

[self unschedule:@selector(updateTimerFunc)];

or:

[self unscheduleAllSelectors];

If you have an update-function you could use: [self scheduleUpdate];

Upvotes: 5

Related Questions