class GmDriver { var car: GmCar! = nil}class GmCar { var driver: GmDriver { dIDSet { driver.car = self } } init() { driver = GmDriver() }}let myCar = GmCar()println(myCar.driver.car) // nil
但是,dIDSet从不触发。为什么?
Apple Documentation:总结The willSet and dIDSet observers of superclass propertIEs are called when a property is set in a subclass initializer,after the superclass initializer has been called. They are not called while a class is setting its own propertIEs,before the superclass initializer has been called.
以上是内存溢出为你收集整理的在Swift中,didSet从init()调用时不会触发,全部内容,希望文章能够帮你解决在Swift中,didSet从init()调用时不会触发,所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)