jjzjj

myOptionalField

全部标签

ios - 是否可以允许在 Swift 初始化期间调用 didSet?

问题Apple'sdocs指定:willSetanddidSetobserversarenotcalledwhenapropertyisfirstinitialized.Theyareonlycalledwhentheproperty’svalueissetoutsideofaninitializationcontext.是否可以在初始化期间强制调用这些?为什么?假设我有这门课classSomeClass{varsomeProperty:AnyObject{didSet{doStuff()}}init(someProperty:AnyObject){self.someProperty=

ios - 是否可以允许在 Swift 初始化期间调用 didSet?

问题Apple'sdocs指定:willSetanddidSetobserversarenotcalledwhenapropertyisfirstinitialized.Theyareonlycalledwhentheproperty’svalueissetoutsideofaninitializationcontext.是否可以在初始化期间强制调用这些?为什么?假设我有这门课classSomeClass{varsomeProperty:AnyObject{didSet{doStuff()}}init(someProperty:AnyObject){self.someProperty=