Block Return Navigation

I have what I consider UX that happens in the background thread. In a method that uses blocks, in success, I call:

[self.navigationController popViewControllerAnimated:TRUE]; 

I am getting a failure, so I think checking the current thread and calling executeSelectorOnMainThread can fix this, but I'm not sure how to configure the @selector part to call.

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

does not work. What is the correct syntax?

+4
source share
2 answers

To force a method to execute the main thread, you can use:

dispatch_async(dispatch_get_main_queue(), ^{
    [self.navigationController popViewControllerAnimated:TRUE]; 
});
+56
source

, , , - , -performSelectorOnMainThread:. self :

- (void)doPop {
  [self.navigationController popViewControllerAnimated:YES];
}

[self performSelectorOnMainThread:@selector(doPop)];

, :

-performSelectorOnMainThread: , , - id. -popViewControllerAnimated: , , BOOL (, , YES NO not TRUE FALSE).

, @selector , , ( self.navigationController).

. , self.navigationController -popViewControllerAnimated: , :

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

, . , pop , . perform , - pop .

+6

All Articles