Viewing the Appdelegate Files

The Appdelegate.h and Appdelegate.m files are created when you create the Xcode project.

The Appdelegate files makes use of the DataVault API to store and retrieve the settings (such as Sybase Unwired Platform credentials).

When the application is launched, the native iOS method didFinishLanunchingWithOptions is called.

- (BOOL)application:(UIApplication *)application
 didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Inside the didFinishLanunchingWithOptions method, initialize two view controllers SettingsViewController and AppPasscodeViewController.

The Navigation Controller is also initialized as a rootViewcontroller of the UI window. If the application is launched for the first time, the SettingsViewController view is called. After the settings are saved and the user is registered, the AppPasscodeViewController view is launched.

/* Initializing SettingsViewController*/
    SettingsViewController *l_firstViewController=[[[SettingsViewController alloc]
    initWithNibName:@"SettingsViewController" bundle:nil] autorelease];
   /* Initializing navigationController with SettingsViewController as rootViewController */
       UINavigationController *navigationController = [[[UINavigationController alloc] 
       initWithRootViewController:l_firstViewController]autorelease];
       [self setM_viewController:navigationController]; 
     /* Setting navigationController as a rootViewController of UIWindow */
        self.window.rootViewController = self.m_viewController;
        @try {
             /*Checks whether specified vault exists. If the value returned is Yes, then initialize
        AppPasscodeViewController and push the AppPasscodeViewController as the first View*/
        if ([DataVault vaultExists:VAULT_NAME])
            {    
              AppPasscodeViewController *passCodeViewCOntroller=[[[AppPasscodeViewController alloc] 
              initWithNibName:@"AppPasscodeViewController" bundle:nil] autorelease];
              [navigationController pushViewController:passCodeViewCOntroller animated:YES];
            }           
            }     
              @catch (DataVaultException *exception)
             {                      
               NSLog(@"Failed with error %@",[exception description]);
       }