Re: NSTimer, and NSTimeInterval help?
Re: NSTimer, and NSTimeInterval help?
- Subject: Re: NSTimer, and NSTimeInterval help?
- From: Marco Masser <email@hidden>
- Date: Sat, 19 Jul 2008 21:53:58 +0200
I'm planning on making a stopwatch where the timer fires and then
the text field updates by each second.
I read online that I should use NSTimeInterval for this, as well as
NSDate, and NSTimer.
My main question is, how do you use NSTimeInterval?
NSTimeInterval is just a typedef for double:
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#/
/apple_ref/doc/c_ref/NSTimeInterval
There is nothing special you have to do. To create a timer that fires
every second, you could do something like this:
[NSTimer scheduledTimerWithTimeInterval:1.
target:self
selector:@selector(doSomething:)
userInfo:nil
repeats:YES];
-doSomething must have the following signature:
- (void)doSomething:(NSTimer *)theTimer
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSTimer_Class/Reference/NSTimer.html#/
/apple_ref/occ/clm/NSTimer/
scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden