Right design/code approach to call a method every N hours
Hi there,
I have a small utility app that's syncing some data from my server. I have a sync method and I would like my app calls this method automatically at certain time on a day.
What is best approach to this? I know I could deploy a timer or something but I don't know if this is the right way of doing this kind of thing...? I want the method to be executed every day at 6AM and 6PM and maybe in future every 4 hours or so...
Any tips and pointers to the right place in ADC documentation would be appreciated.
Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.
so is this a good practice to have this timer running at all time and waiting to the right hour to come?
I can't see why it's a bad practice.
I observe that there're Time Manager functions inside CoreServices framework, but all of it has been deprecated since Mac OS X 10.4, so they advise to use Carbon Event Loop or NSTimer.
My understanding of NSTimer is it will run based on the schedule of the main application event loop, so I don't think it's something that will consume lots of resources, besides the fact that you're doing this on the desktop.
Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.
Writing code is not only about writing instructions to a machine / computer, but also about writing something that could be read, understood, and maintained by others. That's why, I like Cocoa.