Uploaded image for project: 'Swift'
  1. Swift
  2. SR-419

Property observers not triggered on other instances of same class

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Medium
    • Resolution: Done
    • Component/s: Compiler
    • Labels:
      None

      Description

      Property observers are not triggered from observers on other instances of the same class:

      class Thing {
          var related: Thing?
          var observerCalled = false
          var property: String = "Initial" {
              didSet {
                  observerCalled = true
                  related?.property = property //should trigger related's observer
              }
          }
      }
      
      let thing = Thing()
      thing.related = Thing()
      thing.property = "New Value"
      print("thing observer called: \(thing.observerCalled) [expected true]") //true
      print("related observer called: \(thing.related!.observerCalled) [expected true]") //false
      

        Attachments

          Activity

            People

            • Assignee:
              originaluser2 Hamish Knight
              Reporter:
              andyvn22 Andy Van Ness
            • Votes:
              2 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: