Arbitur Arbitur - 21 days ago 7
iOS Question

Attempting to store to property '' within its own willSet

Im getting a weird warning in the editor which I need help understanding what it wants

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 { ... }
}


When I run it it is doing what I want it to do with no crashes or warnings in console, so I see this as just a false positive. So can I suppress it in any way because its annoying? :(

Answer

This is a known bug, reported in the Apple Developer Forum: https://devforums.apple.com/message/1065306#1065306, with the workaround of adding an explicit self:

    willSet {
        self.someProperty?.someFunction()
    }

Update: I could not reproduce the issue with Xcode 7.3.1 or Xcode 8 anymore, so that seems to be fixed now.

Comments