2:代码演示
// 监听类的属性的改变-属性监听器 class Person: NSObject { var name : String? { // 属性已经改变的时候监听 didSet { print(name) print(oldValue) } } } let p1 = Person() p1.name = "李胜兵" if let name = p1.name { print(name) } p1.name = "符小姐" if let name = p1.name { print(name) }
意见反馈邮件:1415429879@qq.com 欢迎你们的阅读和赞赏、谢谢!
原文链接:https://www.f2er.com/swift/323281.html