2015-04-18 36 views

回答

0

UIApplication.sharedApplication().delegate給對單應用對象,所以:

let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate 
let x = appDelegate.myVariable 
+0

所以我只想調用這個一遍又一遍,以訪問變量? – Schuey999

+0

在您的viewController中創建'appDelegate'作爲實例變量,您可以在viewController的所有方法中訪問它。 – zisoft

+0

好的會嘗試一下。謝謝! :) – Schuey999

相關問題