Re: creating multiple NSTimers
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