appDelegate.swiftに変数を作成し、アプリ全体で使えるグローバル変数にする。
AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var count:Int = 0
}
ViewController.swift
//delegateオブジェクトを作る
let delegate:AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
delegate.count = 10 //このようにして、データを代入したり、やり取りを行ったりする