application design/architecture question for a project that I am building.
I have a main controller which holds an NSMutableArray of currently “active” objects.
Each one of those objects, when instantiated, will have their own NSTimer that is timing the amount of seconds / minutes / hours that the object is in an “active” state.
Should I be generating and allocating these NSTimers on their own separate thread when a user creates the new object? Or can I have multiple timers like this running on the main thread?
Not that familiar with threading so that is why I’m asking. If each object has it’s own NSTimer allocated then threading isn’t necessary? or…?
I don’t think you need NSTimer for this. NSTimer is used to fire a callback after a set amount of time. If you are trying to track the amount of time since an object has been created, do this:
Upon making object active:
To determine how long the object has been active, do this:
pausable implementation
I wrote a category you can add to your project that you can use to track ‘active time’ for objects.