Inspired by @PeterHosey's interesting comment in this question, I decided to implement usage time tracking system.
Like:
- The app starts, the counter starts
- The app terminates, the whole duration is logged
- At any point (even during execution), that the total usage time exceeds the allowed time, the user receives a notification
However, I'm having a couple of... conceptual issues:
- What am I going to track? Would
[NSDate date]suffice? - What if the user simply changes his system date/time at some point?
- Also, which specific delegate methods are to be hooked? I mean, where would you call the start/stop routines for the counting functions?
I'm all ears! :-)
Well, I don't think you need to use [NSDate date] approach for this. Why don't you use mach_absolute_time() function? To track the time elapsed, it may be some timer (ticks, for example, each minute).
GCD-timers is a simple flexible way to implement timers, which you may suspend and resume if need (for example, if you want to suspend it while the program is not in use.).