• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTimer, and NSTimeInterval help?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSTimer, and NSTimeInterval help? (From: Eric Lee <email@hidden>)

  • Prev by Date: Re: NSTimer, and NSTimeInterval help?
  • Next by Date: Re: Autosaving in an NSPersistentDocument
  • Previous by thread: Re: NSTimer, and NSTimeInterval help?
  • Next by thread: Re: NSTimer, and NSTimeInterval help?
  • Index(es):
    • Date
    • Thread