first loaded means first time ever? or for every new launch? this code is for first time ever, but without NSUserDefault
can be used to every new launch
appDelegate.h
@property (strong, nonatomic) UIWindow *window;
appDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3];
UITabBarItem *tabBarItem5 = [tabBar.items objectAtIndex:4];
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"first"]) {
//first launch selected third tabBarItem
tabBarController.selectedIndex = 2;
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"first"];
}