import UIKit
class ViewController: UIViewController {
//靜態變量 swift中的static靜態變量,只能在這里聲明,不能在方法中聲明,會報錯
static var i : Int = 1
override func viewDidLoad() {
super.viewDidLoad()
//調用靜態變量
// print(self.i) 錯
print(ViewController.i) //這樣調用
// 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.
}
}