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 10-30-2009, 04:52 PM   #1 (permalink)
Registered Member
 
LiquidChaz's Avatar
 
Join Date: Sep 2009
Location: New York City
Posts: 53
LiquidChaz is on a distinguished road
Default Determining a "first fire" with an NSTimer

I'm using a repeating NSTimer for my game that is initialized when my view loads. There's an "if" statement in my selector method that waits for the a boolean value to equal YES, effectively starting the timer until the boolean value returns to false.

So here's my issue:

If the NSTimer is defined as repeating every 10 seconds, the first time my code is fired (immediately after the boolean value is set to YES) could actually be any random time value between 1 & 10.. because the timer is randomly firing even thought the boolean is false.

Is there a more reliable way to use the timer so that I get a full 10 second interval immediately after my boolean is set to YES?

I can think of a work around that suits my needs... basically, set the NSTimer to fire every 1 second and include a tick integer so that the selector method runs every time the tick gets to 10...

... but I'm still curious... is there a more efficient solution or a more efficient way to use NSTimer in general?

Thanks!
__________________
Charles Scalesse

Latest Release:
Mad Bomber - A contemporary twist on the Atari 2600 classic, Kaboom!

LiquidChaz is offline   Reply With Quote
Old 10-30-2009, 05:53 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Michigan
Posts: 30
tpurves is on a distinguished road
Default

If I am understanding what you are saying correctly, I would recreate the timer in the new view load. Then it will fire 10 seconds later.
tpurves is offline   Reply With Quote
Reply

Bookmarks

Tags
nstimer

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: 347
10 members and 337 guests
alexP, ClerurcifeDer, Duncan C, givensur, glenn_sayers, guusleijsten, JmayLive, Punkjumper, whitey99, yys
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,883
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

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