When I go back from my secondView to my mainView I’m processing something in the viewDidDisappear method of my secondView. The problem is, my mainView gets stuck due to the work the app has to do.
Here is what I do:
-(void)viewDidDisappear:(BOOL)animated
{
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul);
dispatch_async(queue, ^{
dbq = [[dbqueries alloc] init];
[[NSNotificationCenter defaultCenter] postNotificationName:@"abc" object:nil];
//the notification should start a progressView, but because the whole view gets stuck, I can't see it working, because it stops as soon as the work is done
dispatch_sync(dispatch_get_main_queue(), ^{
//work
});
});
What am I doing wrong?
Thanks in advance!
You need to perform your work in the
dispatch_asyncto yourqueue. You are currently doing the work (assuming the// Workcomment is where it goes) in the main thread, and in addition you are blocking your worker thread waiting for this work.Try to rearrange your GCD calls a bit: