• 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: NSDate, NSTimer, NSTimeInterval combined question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: NSDate, NSTimer, NSTimeInterval combined question


  • Subject: re: NSDate, NSTimer, NSTimeInterval combined question
  • From: Allison Newman <email@hidden>
  • Date: Sat, 2 Aug 2008 08:04:45 +0200

Eric,

Without looking too closely, I see several problems, there may be others.

Firstly, in your updateTextfield method, you are using startTimewithout initialising it.

Secondly, in your timer callback (updateTextfield), you never update the value of your clock gadget, so of course it doesn't change.

Thirdly, as far as I can tell, you aren't correctly setting the interval for the timer - you seem to be setting it to 0. I don't know what that does to the system.

When using a timer, I generaly find it easier to do this:
timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:updateTextfield userInfo:nil repeats: true];


This repets with an interval of 1.0 seconds (syntax may be wrong for the selector, I use RubyCocoa, not Objective-C).

Using this call, you don't need to use a runloop at all, it's all automagically handled for you. All you need to do is call [timer invalidate] when you want to stop the timer.

Hope that helps.

Alli
_______________________________________________

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


  • Prev by Date: IKImageBrowser drag reordering question/problem
  • Next by Date: Re: NSDate, NSTimer, NSTimeInterval combined question
  • Previous by thread: Re: NSDate, NSTimer, NSTimeInterval combined question
  • Next by thread: IKImageBrowser drag reordering question/problem
  • Index(es):
    • Date
    • Thread