I am running a bunch of items in the background using dispatch_async and sometimes I want to kill what I have in the queue - is this possible? For instance this code is run on a view, and then the user goes back a screen. All of these fired actions keep running regardless of the back navigation. Ideally I would like to kill these items from running:
dispatch_async(dispatch_get_global_queue(2, 0), ^{
for (int i=0; i<[self.manufacturers count]; i++) {
NSString *manufacturerID = [[[self.manufacturers objectAtIndex:i] ManufacturerID] stringValue];
[self doSync:manufacturerID withIndex:i setTimer:YES];
}
});
If I create a queue and name it and then release it on the dealloc of the view this is called in they still continue to run.
See Question&Answers more detail:os