I have NSOperationQueue that runs on another thread than the whole application. I'm adding NSOperation to the queue that in main has
-(void)main{
[self updatePallets];
NSTimer * timer = [NSTimer scheduledTimerWithTimeInterval: 5.0 target:self selector: @selector(updatePallets) userInfo: nil repeats: Yes];
NSRunLoop * runLoop = [NSRunLoop currentRunLoop];
[runLoop addTimer:timer forMode: NSRunLoopCommonModes];
[runLoop run];
}
And it works fine as I wanted. But how to cancel this type of operation. On My main thread I want to for example do something like this:
[queue cancelAllOperations];
[queue waitUntilAllOperationsAreFinished];
And I want to hang main thread and wait until it is finished. And then perform some actions. But It does not cancel any operation (there'is only one with the timer) what I should do? I tried also to add new operation to the queue after dispatcher pop time, but still can't stop it.