I have this annoying problems and it seriously driving me nuts.
I've made a NSTimer set for autorepeating every 0.5 sec but sometimes it repeats 10 times and then stops, sometimes 2 times and stops and sometimes it doesn't start at all.
I've get this in
GameView.h
Code:
NSTimer *fpsUpsTimer;
...
- (void)updateFpsUps:(NSTimer *)timer;
and in GameView.m
in the main thread I've tried
Code:
fpsUpsTimer = [NSTimer scheduledTimerWithTimeInterval: 0.5
target: self
selector: @selector(updateFpsUps:)
userInfo: nil
repeats: YES];
[fpsUpsTimer retain];
and I've tried
Code:
fpsUpsTimer = [NSTimer timerWithTimeInterval: 0.5
target: self
selector: @selector(updateFpsUps:)
userInfo: nil
repeats: YES];
[fpsUpsTimer retain];
[[NSRunLoop mainRunLoop] addTimer:fpsUpsTimer forMode:NSDefaultRunLoopMode];
[fpsUpsTimer fire];
and then I've tried that in separate thread and added timer to thread's run loop
my timer handler looks like this
Code:
- (void)updateFpsUps: (NSTimer *) timer
{
fps = frames*2;
ups = updates*2;
frames = updates = 0;
NSLog(@"\nfps: %d ups: %d", fps, ups);
}
So, why the heck this stupid timer doesn't feel like firing anymore and every time it behaves differently?