Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ethana

macrumors 6502a
Original poster
Jul 17, 2008
836
0
Seattle, WA
I'm trying to create an app that has a Stopwatch type feature in it, but I want to type as little code as possible to do it. Basically, I want to have exactly what the Clock>Stopwatch iPhone app has and put it right into one of my apps.

Anyone have any clue if this can be done easily? Or do I have to do this the hard way with timers, loops, etc. Please post reusable code if you can. Thanks!

Ethan
 

detz

macrumors 65816
Jun 29, 2007
1,051
0
No loop, you app will lock up. Use a timer, easy enough...

[NSTimer scheduledTimerWithTimeInterval:(1)
target:self
selector:mad:selector(goDude)
userInfo:nil
repeats:YES];

-(void)goDude{
//every second this is called.
}
 

alexalol

macrumors newbie
Aug 1, 2008
2
0
hi
i am new to iphone programming and just want to know just how accurate can this "stopwatch" app be made; can it only count seconds or can it be made to count tens (0.1s) and hundreds (0.01s) of a second?
 

detz

macrumors 65816
Jun 29, 2007
1,051
0
hi
i am new to iphone programming and just want to know just how accurate can this "stopwatch" app be made; can it only count seconds or can it be made to count tens (0.1s) and hundreds (0.01s) of a second?

NSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.