我在编辑器中收到一个奇怪的警告,我需要帮助来理解它想要什么
Attempting to store to property 'someProperty' within its own willSet, which is about to be overwritten by the new value
var someProperty:SomeClass! {
willSet { someProperty?.someFunction() } // Get warning: Attempting to store to property 'someProperty' within its own willSet, which is about to be overwritten by the new value
didSet { ... }
}
当我运行它时,它正在执行我希望它执行的操作,控制台中没有崩溃或警告,所以我认为这只是一个误报。那么我可以以任何方式抑制它,因为它很烦人吗? :(
最佳答案
这是一个已知错误,已在 Apple 开发者论坛中报告:https://devforums.apple.com/message/1065306#1065306 , 解决方法
添加显式 self
的方法:
willSet {
self.someProperty?.someFunction()
}
更新:我无法使用 Xcode 7.3.1 或 Xcode 8 重现该问题 不再存在了,所以现在似乎已经解决了。
关于ios - 试图在自己的 willSet 中存储属性 '',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29343654/