Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How to make running timer

How to make running timer
Thread Tools
Fresh-Faced Recruit
Join Date: Jan 2004
Location: Helsinki, Finnland
Status: Offline
Reply With Quote
Oct 25, 2005, 01:35 PM
 
Hello Guys

Tried to look old topic but didn't find.

Can anyone give clues hot to make a timer which sarts to run up when I press a button and stop when I press other button. I need the time to run at the screen. Mins and Secs. I know how to use buttons but need help with timer stuff.

Thanks in advance
TumppiH
     
Junior Member
Join Date: Mar 2000
Location: Salem, OR, USA
Status: Offline
Reply With Quote
Oct 25, 2005, 06:45 PM
 
What language?

The exact implementation will depend on what language you use, but here's the general idea:
1) When "start" button is pushed get and save the system time.
2) In your "clock display" display the time difference between now and when you push "start".
3) Repeat step #2 until the "stop" button is pushed.

Let me know if this doesn't answer your question.

--numero
     
TumppiH  (op)
Fresh-Faced Recruit
Join Date: Jan 2004
Location: Helsinki, Finnland
Status: Offline
Reply With Quote
Oct 26, 2005, 01:37 AM
 
Originally Posted by numero
What language?

The exact implementation will depend on what language you use, but here's the general idea:
1) When "start" button is pushed get and save the system time.
2) In your "clock display" display the time difference between now and when you push "start".
3) Repeat step #2 until the "stop" button is pushed.

Let me know if this doesn't answer your question.

--numero
Sorry my mistake

I'm coding in Cocoa, Objective-C with Xcode. If you have anymore advice please tell.
TumppiH
     
Senior User
Join Date: Feb 2001
Location: Deer Crossing, CT
Status: Offline
Reply With Quote
Oct 26, 2005, 02:21 PM
 
Here is Apple's developer documentation on the NSTimer object. You'll probably want to make use of NSTimer so you can update the time elapsed in your program's window.

I'm sure if you do a google on NSTimer example you'll find some sample code that'll set you on your way.
20" iMac G5! :D AND MacBook 1.83GHz!
Canon Digital Rebel Kit + 75 - 300mm lens. Yum Yum! :D
Check out my OS X Musical Scales program
     
   
Thread Tools
Forum Links
Forum 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
Top
Privacy Policy
All times are GMT -5. The time now is 07:40 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2