// Swift懒加载使用lazy关键字来修饰属性
// 在属性后面跟= {}进行具体的赋值
// 只会被加载一次
lazy var names : [String]? = {
// () -> ([String]) in
print("加载数据")
return ["why", "lnj", "lmj"]
}()
override func viewDidLoad() {
super.viewDidLoad()
}
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
print(names);
print(names);
print(names);
print(names);
}
时间: 2024-10-27 09:02:16