I am using a thread to update messages in background in my application. The thread is started in my messages class.
Messages.m
ti
[timerThread cancel]
doesn't stop thread, it just marks it as cancelled. I presume that your startTimerThread:
performs some sort of infinite loop. You have to check isCancelled
in this loop periodically and if it's YES you should perform some clean up and break from this loop.
BTW if you don't perform updates frequently it is more convenient to run NSTimer
in main thread and detach new thread on callbacks (like [self performSelectorInBackground:@selector(updateMessages:) withObject:whatever]
) or start an instance of NSOperation
.