Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-26-2010, 08:11 AM   #1 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 1
dziki_zbik is on a distinguished road
Default NSTimer stops repeating

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?
dziki_zbik is offline   Reply With Quote
Reply

Bookmarks

Tags
nstimer, thread, timer

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 344
7 members and 337 guests
dre, freewind, hain, HemiMG, lendo, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:59 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0