Moving from one tab to another programmatically

"How do you move from one tab to another programmatically?"

This is a question that always seems to crop up and it turns out the answer to that question is a single line of code:

self.tabBarController.selectedIndex = 6;

Changing the selectedIndex value on a UITabBarController will cause it to open the tab at that index. 6 in this case refers to the order of the tab, starting from 0 for the left most tab.

Another useful operation is the return the present tab back to its root controller:

[self.navigationController popToRootViewControllerAnimated:NO];

What do you think? Let me know by getting in touch on Twitter - @wibosco