• 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: creating multiple NSTimers
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating multiple NSTimers


  • Subject: Re: creating multiple NSTimers
  • From: Greg Guerin <email@hidden>
  • Date: Thu, 29 Sep 2011 22:50:22 -0700

Gordon Apple wrote:

> There must already be an array for the table, so just iterate the array every
> minute or whatever (single repeating timer), compare the times to [NSDate
> date} and start or shut down whatever has not been started or shut down. Much
> easier than trying to manage timers.


You don't have to iterate the whole array, either. Sort it by ascending order of turn-off time. Keep a current position (index). If the time of day is less than the turn-off time of the device at the current position, do nothing. If time of day >= turn-off time of current position, then turn it off and advance position until time of day is again less than the turn-off time of device at the current position. Only needs one timer, and scales to as large an array as you want to keep.

  -- GG

_______________________________________________

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


  • Follow-Ups:
    • Re: creating multiple NSTimers
      • From: Conrad Shultz <email@hidden>
  • Prev by Date: Finder Integration
  • Next by Date: Re: Core Data : Undo Delete : Cannot fulfill a fault
  • Previous by thread: Re: creating multiple NSTimers
  • Next by thread: Re: creating multiple NSTimers
  • Index(es):
    • Date
    • Thread