Re: creating multiple NSTimers

2011-09-30 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/29/11 10:50 PM, Greg Guerin wrote: 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

Re: creating multiple NSTimers

2011-09-30 Thread Thomas Davie
On 30 Sep 2011, at 08:19, Conrad Shultz wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/29/11 10:50 PM, Greg Guerin wrote: 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

Re: creating multiple NSTimers

2011-09-30 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/30/11 12:29 AM, Thomas Davie wrote: When the user updates a timer, one is forced to re-sort the array and reposition the index (under the above implementation). Why would you need to resort? Just remove, and reinsert. OK, I'll grant you

Re: creating multiple NSTimers

2011-09-30 Thread Tom Hohensee
Thanks for the discussion. What I implemented last night was what Graham had suggested. I simply bind my table column values to an NSArrayController controller and observed by KVO in my set box object. It works great. I think this is also what Conrad had meant as well. Simply changing the

creating multiple NSTimers

2011-09-29 Thread Tom Hohensee
For the life of me I cannot figure this one out. I need to create an indeterminate amount of timers for an app I am working on. The app is petty simple. For example, provide a list of ip enabled devices with times to shut off and the app executes the device's shutdown at the specified time.

Re: creating multiple NSTimers

2011-09-29 Thread Eric E. Dolecki
Can't you use a loop and then stuff the timers into an NSMutableArray or NSMutableDictionary to access? On Thu, Sep 29, 2011 at 5:47 PM, Tom Hohensee tom.hohen...@gmail.comwrote: For the life of me I cannot figure this one out. I need to create an indeterminate amount of timers for an app I

Re: creating multiple NSTimers

2011-09-29 Thread David Duncan
On Sep 29, 2011, at 2:47 PM, Tom Hohensee wrote: However, I do not know wether the user will have 1 device or 100 devices. Do I have to setup a finite amount of timers (ultimately having a limit on the number of devices that can be added) or is there a better way? I have googled for a

Re: creating multiple NSTimers

2011-09-29 Thread Tom Hohensee
Yes. What I have worked on is using an array of timers fired sequentially. Each firing of the timer sets up the next one in the array. Each new addition to the array requires invalidating of the active timer and reordering of the array according to times. But i have run into problems when

Re: creating multiple NSTimers

2011-09-29 Thread David Duncan
I think you need to backup and explain exactly what your requirements are. If you really do need to track these timers, you will probably need an array or dictionary, but if these timers are all one-shot and they configure the next timer to execute, there seems little reason to maintain your

Re: creating multiple NSTimers

2011-09-29 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/29/11 3:06 PM, Tom Hohensee wrote: Yes. What I have worked on is using an array of timers fired sequentially. Each firing of the timer sets up the next one in the array. Each new addition to the array requires invalidating of the active

Re: creating multiple NSTimers

2011-09-29 Thread Jens Alfke
On Sep 29, 2011, at 3:06 PM, Tom Hohensee wrote: Yes. What I have worked on is using an array of timers fired sequentially. Each firing of the timer sets up the next one in the array. Each new addition to the array requires invalidating of the active timer and reordering of the array

Re: creating multiple NSTimers

2011-09-29 Thread John Pannell
Hi Tom- Could you use a single, repeating timer with sufficient resolution for your purposes and an array or dictionary storing the needed timing state? Then update state appropriately at each fire of the single timer? Array { Timing Item 1 { currentTime: 24.2

Re: creating multiple NSTimers

2011-09-29 Thread Tom Hohensee
Sorry, I started this out wrong. I am probably over thinking this to the point of confusion. Here is where I am. I have an application for a facility that uses a number of ip enabled set top boxes to drive TV's throughout the place. Each box is to be shutdown at certain times of the day

Re: creating multiple NSTimers

2011-09-29 Thread Jamie Pinkham
Forgot to send to list: Perhaps, instead of timers, you use objects that represent one of these set-top boxes and the time at which they should be shutdown. And instead of scheduling and managing timer, you manage the domain objects instead. Then, you have one timer, that checks all of

Re: creating multiple NSTimers

2011-09-29 Thread Graham Cox
Timers are objects, and can be retained like any other independently of whether they are scheduled on a run loop or not. The run loop will additionally retain the timer, but that's its business. In the object that represents the set-top box, just add a 'timer' property (retained), so that you

Re: creating multiple NSTimers

2011-09-29 Thread Conrad Shultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/29/11 4:48 PM, Tom Hohensee wrote: Sorry, I started this out wrong. I am probably over thinking this to the point of confusion. Here is where I am. I have an application for a facility that uses a number of ip enabled set top boxes to

Re: creating multiple NSTimers

2011-09-29 Thread Tom Hohensee
Bingo! Thanks. This is where I was going wrong. I saw John and Jamie's responses earlier and got me thinking in objects again. But still wasn't putting it together. I had a mental block and was not thinking of the timers as properties of the boxes. Just kept getting stuck on the NSTimer

Re: creating multiple NSTimers

2011-09-29 Thread Gordon Apple
Whoops, didnĀ¹t reset the title. Sorry. On 9/29/11 8:25 PM, Gordon Apple g...@ed4u.com 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

Re: creating multiple NSTimers

2011-09-29 Thread Greg Guerin
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