最終更新:2017-07-11 (火) 04:50:39 (75d)  

Objective-C/起動プロセス はてなブックマークを見る
Top / Objective-C / 起動プロセス

AppKit

UIKit

main.m

例:Single View Application

  • #import <UIKit/UIKit.h>
    
    #import "AppDelegate.h"
    
    int main(int argc, char *argv[])
    {
        @autoreleasepool {
            return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
        }
    }

AppDelegate.m (AppDelegate - UIApplicationDelegate)

例:Single View Application

  • Storyboardを使う場合
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        // Override point for customization after application launch.
        return YES;
    }
  • Storyboardを使わない場合
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
        } else {
            self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
        }
        self.window.rootViewController = self.viewController;
        [self.window makeKeyAndVisible];
        return YES;
    }

ViewController.m (ViewController - UIViewController)

例:Single View Application

  • - (void)viewDidLoad
    {
        [super viewDidLoad];
    	// Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

メモ

その他

アクティブ化(フォアグラウンド化/起動)した時

フォアグラウンド状態から抜けようとしている時 (バックグラウンド化)

終了前

参考