Here is part of my program. Loop in findDuplicates starts in background thread after button was pressed. Is there any way to stop/kill thread/loop by pressing another button?
- (IBAction)countDups:(id)sender {
[self performSelectorInBackground:@selector(findDuplicates) withObject:nil];
}
-(void)findDuplicates
{
...
for(int index=0;index<self.resultList.count;index++)
{ ... }
...
}
You can return from background thread. create one member variable, initialize it with NO.