Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation from block return

I have what I think is a UX operation happening on a background thread. In a method that uses blocks, in the success I am calling:

[self.navigationController popViewControllerAnimated:TRUE]; 

I am getting a crash, so I am thinking that checking the current thread and calling performSelectorOnMainThread might fix this, but I am not sure how to setup the @selector portion of the call.

[self performSelectorOnMainThread:@selector([self.navigationController popViewControllerAnimated:TRUE]) withObject:nil waitUntilDone:NO];

is not working. What is the proper syntax?

like image 375
Rob Bonner Avatar asked Nov 27 '22 20:11

Rob Bonner


1 Answers

To force the method to perform on the main thread you can use:

dispatch_async(dispatch_get_main_queue(), ^{
    [self.navigationController popViewControllerAnimated:TRUE]; 
});
like image 104
Lyndsey Scott Avatar answered Dec 06 '22 23:12

Lyndsey Scott