iOS: Is this a good way to wait for push view controller to finish?

I’ve seen the following code on stackoverflow with a lot of up votes

[CATransaction begin];
[[self navigationController] pushViewController:viewController animated:YES];
[CATransaction setCompletionBlock:^{
    //whatever you want to do after the push
}];
[CATransaction commit];

I am currently using this and it solves my issues completly. However, I want to be sure if this is okay to use and doesn’t have any pit falls I may be unaware. Sorry, but I am a little nervous about using this because I am not 100% sure if this is okay to use. As reasurance I am posting this question hoping to get some insight.

Hi @sweetoothj,
I am not sue if you really need to encapsulate a pushViewController in a CATransaction other than to be able to have the completionBlock. With presentViewController you get a parameter called completion that lets you pass a closure to run when the presenting of the viewcontroller is completed.

cheers,

Jayant

This topic was automatically closed after 166 days. New replies are no longer allowed.