didSet not working as expected

If I try the example from the Swift guide as shown below. I am getting errors, such as (not relevant to the below code but it’s the same error):

    /Users/x/Documents/FireExperiment/RippleApp/CardStackViewLayout.swift(11,19): error E525: Cannot invoke data value
    /Users/x/Documents/FireExperiment/RippleApp/CardStackViewLayout.swift(11,19): error E62: Type mismatch, cannot assign "method that returns no value" to "Int"
    /Users/x/Documents/FireExperiment/RippleApp/CardStackViewLayout.swift(11,19): error E525: Cannot invoke data value

The example comes from this page:
https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Properties.html

Code snippet:

class StepCounter {
    var totalSteps: Int = 0 {
        willSet(newTotalSteps) {
            print("About to set totalSteps to \(newTotalSteps)")
        }
        didSet {
            if totalSteps > oldValue  {
                print("Added \(totalSteps - oldValue) steps")
            }
        }
    }
}

Thanks, logged as bugs://73134

bugs://73134 got closed with status fixed.

Great thanks!

I can confirm this problem doesn’t occur. When I compile my code with Xcode and my code block gets triggered. The oldValue is nil while in Fire it’s not returning nil when assigning it for the first time.

Consider this:

  var photo: Photo? {
   didSet {
        if oldValue == nil {
              imageView.alpha = 0
        }
   
        if let photo = photo {
                imageView.image = photo.image
        }
     }
  }

If I set a breakpoint on the if-statement with oldValue I am getting nil in xCode and in Fire the value of oldValue is the same as value. As the watches list in Fire doesn’t show oldValue when setting the breakpoint I digged it up through by adding let myOldValue = oldValue. I even tried to do var photo: Photo? = nil { blah } but that didn’t change anything.

I have made screenshots but I don’t knowhow to attach them to this message. I can email them if you want. The above code snippet is in the project I send you guys on Friday evening.