Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to setup first time launch of an iOS App

    • 0
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.81k
    Comment on it

    Hello reader's !

    If you want to setup first time launch of an iOS app. Using this code the terms and conditions will appears or shown only the first time of app launch.
    here is the code below.

    I have two UIViewControllers (FirstViewController and AlreadyRunViewController). FirstViewController is for "Terms and Condition" page and if app is not running for first time then AlreadyRunViewController will appear .

    So I have these files in my XCode :

    alt text


    Now, Go to to storyboard and give StoryBoard Id to "terms and condition" view controller.

    alt text


    Then go to your AppDelegate.m and paste below code :-

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        if ([[self alreadyRunOrNot] isEqualToString:@"runalready"]) {
            NSLog(@"alreadyrun");
    
        }
        else
        {
            NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
            //   saving user details to NSUserDefaults
            [prefs setObject:@"runalready" forKey:@"alreadyRunOrNot"];
            NSLog(@"run first time");
            UIStoryboard *story=[UIStoryboard storyboardWithName:@"Main" bundle:nil];
            FirstViewController *firstVC = [story instantiateViewControllerWithIdentifier:@"firstViewController"];
            self.window.rootViewController =firstVC;
        }
        return YES;
    }  
    


    Now storyboard will look like :-

    alt text

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: