I have a certain object that perform a "Refresh" every X seconds. ("The Updater")
The way I'm doing this repetitive update is by calling performSelector:withObject:afterDelay
and in my selector I'm re-scheduling as necessary.
Of course I have a method to stop these invokations by calling cancelPreviousPerformRequests
.
The problem is that this "Updater" is never being deallocated.
There is only one other object that retaining the Updater (AFAIK), and the retaining object is being deallocated and calls [self setUpdater:nil];
I'm suspecting that this is have something to do with the performSelector:withObject:afterDelay
method, but I couldn't find any reference to that question in the documentation.
Can anyone confirm or dismiss it?
Thanks!
APPENDIX This are the scheduling methods:
-(void) scheduleProgressUpdate
{
[self stopProgressUpdates]; // To prevent double scheduling
[self performSelector:@selector(updateProgress)
withObject:nil
afterDelay:1.0];
}
-(void) updateProgress
{
// Perform update..
[self scheduleProgressUpdate];
}
-(void) stopProgressUpdates
{
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(updateProgress)
object:nil];
}