LoginSignup
13
13

More than 5 years have passed since last update.

Single View Application Project - ViewController.swiftの解説

Last updated at Posted at 2014-06-29

Single View Application Projectを作成した時、以下のswiftファイルがデフォルトで作成されます。

  • AppDelegate.swift
  • ViewController.swift

本ブログではViewController.swiftについて解説します。

ViewController.swift
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

UIKitフレームワークをインポートする。
UIKit Framework Reference(英文)はこちら>>

import UIKit

UIViewControllerを継承したViewControllerクラスを作成する。
※UIViewControllerとは
すべてのiOSアプリケーションのための基本的なビューの管理モデルを提供するクラス

class ViewController: UIViewController {

UIViewControllerで定義されたviewDidLoadメソッドを再定義する。
viewDidLoadはビューの読み込みが終了した時に呼ばれるメソッド。初期値では親クラスのviewDidLoadメソッドを呼び出ししているが、必要に応じて処理を加える。

override func viewDidLoad() {
    super.viewDidLoad()
}

UIViewControllerで定義されたdidReceiveMemoryWarningメソッドを再定義する。
didReceiveMemoryWarningはアプリケーションがメモリ不足の警告を発した時この呼ばれるメソッド。必要に応じて処理を加える。

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

IOS8アプリ開発日誌掲載中!!

13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13