NSTimer in iphone program?
I am developing a viewbased program for iphones. I have lots of .xib files.
It is basically a trivia game.
I am trying to make it so that the program times how long it takes them to get to the end. How can i get one timer to show up on all the pages and then stop once they get the last question right(and start with a button at the beginning) and display the time.
Please be as descriptive as you can because I've never developed an iphone app before and im trying to learn c/objective c as i make this app.
Put the time in the app delegate and access it from there. Or create a Singleton class for the timer. Searching for those terms on the forum will get you lots of results in previous threads.
If you don't want to display the time as the app is running, then you don't want an NSTimer - instead, you want an NSDate variable that is set to [NSDate date] when the clock starts; if you call it, say, startTime, you can then use something like:
to get the number of seconds (with fractional seconds) between when you started and when you finished. (Note the minus sign after the equals sign; since Start Time is in the past, using timeIntervalSinceNow returns a negative number.)
Put the time in the app delegate and access it from there. Or create a Singleton class for the timer. Searching for those terms on the forum will get you lots of results in previous threads.
I tried putting code into delegate but then what .xib file do i tag the label (the one that shows the time). None of the .xibs have a "connection" for the time
If you don't want to display the time as the app is running, then you don't want an NSTimer - instead, you want an NSDate variable that is set to [NSDate date] when the clock starts; if you call it, say, startTime, you can then use something like:
to get the number of seconds (with fractional seconds) between when you started and when you finished. (Note the minus sign after the equals sign; since Start Time is in the past, using timeIntervalSinceNow returns a negative number.)