Swift - 在其它类获取Appdelegate单例的属性或对
2017-09-20 本文已影响0人
麦志超
1. 获取Appdelegate
let myAppdelegate = UIApplication.shared.delegate as! AppDelegate
2. 获取Appdelegate的属性
if myAppdelegate.xx != nil
{
xx = myAppdelegate.xx
}
let myAppdelegate = UIApplication.shared.delegate as! AppDelegate
if myAppdelegate.xx != nil
{
xx = myAppdelegate.xx
}