Implementation of the AppDelegate Class

Let us begin with reviewing the implementation of the AppDelegate class.

The AppDelegate class is based on the template generated by Xcode and includes the following two processes:

Check the source code below.

Swift

Objective-C

Initialization of the Kii Cloud SDK

When Kii Balance starts, the application(_:didFinishLaunchingWithOptions:) method is called and initializes the Kii Cloud SDK.

The SDK is initialized in the same way as that in Hello Kii. For more information, see Implementation of the AppDelegate Class in the Hello Kii tutorial.

Transition between the title screen and the data listing screen

The AppDelegate class defines the methods for screen transitions between the title screen and the data listing screen.

In order to provide the user interface shown in the previous topic, Class Structure, the user interface below is defined in the storyboard.

The title screen and the data listing screen are not connected by any segue. The mobile app switches these screens by specifying the screen ID.

The AppDelegate class defines the following methods for screen transitions.

  • func showTitle() {
      let navigation = self.window!.rootViewController! as! UINavigationController
      let next = navigation.storyboard!.instantiateViewController(withIdentifier: "Title")
      navigation.setViewControllers([next], animated: true)
    }
    
    func showBalanceList() {
      let navigation = self.window!.rootViewController! as! UINavigationController
      let next = navigation.storyboard!.instantiateViewController(withIdentifier: "BalanceList")
      navigation.setViewControllers([next], animated: true)
    }
  • - (void) showTitle {
      UINavigationController *navigation = (UINavigationController*)self.window.rootViewController;
      UIViewController *next = [navigation.storyboard instantiateViewControllerWithIdentifier:@"Title"];
      [navigation setViewControllers:@[next] animated:YES];
    }
    
    - (void) showBalanceList {
      UINavigationController *navigation = (UINavigationController*)self.window.rootViewController;
      UIViewController *next = [navigation.storyboard instantiateViewControllerWithIdentifier:@"BalanceList"];
      [navigation setViewControllers:@[next] animated:YES];
    }

In the title screen and the data listing screen, these methods are called to make screen transitions according to the internal state of the mobile app and the user action.


What's Next?

Let us review the implementation of the title page.

Go to Implementing the Title Screen.