I wish the first time anyone loads my application to have it start at the preferences view i have and every other time to start at the main view.
I could not find a way to detect if this is the first time the application is run. any ideas?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch
NSUserDefaults *padFactoids;
int launchCount;
padFactoids = [NSUserDefaults standardUserDefaults];
launchCount = [padFactoids integerForKey:@"launchCount" ] + 1;
[padFactoids synchronize];
NSLog(@"this is the number: %i of times this app has been launched", launchCount);
if ( launchCount == 1 )
{
NSLog(@"this is the FIRST LAUNCH of the app");
// do stuff here as you wish
bbb = [[Blue alloc]init];
[window addSubview:bbb.view];
}
if ( launchCount >= 2 )
{
NSLog(@"this is the SECOND launch of the damn app");
// do stuff here as you wish
rrr = [[Red alloc]init];
[window addSubview:rrr.view];
}
[window makeKeyAndVisible];
return YES;
}
here Red & Blue are subclasses of uiviewcontroller in both classes only one difference is that in -(void)viewDidLoad{ self.view.backgroundcolor = [UIColor redColor]; }in case of Red class & in blue class which shows blue backgroundcolor but when i execute app its shows only blue color not show red color where i wrong what i do for when i ran app IInd time it shows red color.....