I have my app is a TabBarController, and I have to take different actions depending on which tab is pressed, so, I delegate TabBarContoller, and I got it.
Now in case a tab which contents a NavigationController is pressed, depending on a database value, the view that should be shown is the first one or the last one, so in Tabs.m:
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
NSArray *viewArrays = [(UINavigationController*)viewController viewControllers];
switch (tabBarController.selectedIndex) {
case 3:
{
NSString *query = @"SELECT * FROM login";
sqlite3_stmt *statement = [[Database alloc] select:query];
if(sqlite3_step(statement) == SQLITE_ROW) {
[(UINavigationController*)viewController popToViewController:[viewArrays objectAtIndex:1] animated:YES];
}
sqlite3_finalize(statement);
break;
}
default:
break;
}
}
The problem is objectAtIndex:1 doesn't exist right now