If you intend to manually post these change events, you must call willChangeValue(forKey:) in willSet . In Swift 4:
var coordinate: CLLocationCoordinate2D { willSet { willChangeValue(for: \.coordinate) } didSet { didChangeValue(for: \.coordinate) } }
Or in Swift 3:
var coordinate: CLLocationCoordinate2D { willSet { willChangeValue(forKey: #keyPath(coordinate)) } didSet { didChangeValue(forKey: #keyPath(coordinate)) } }
Or, which is much simpler, just specify it as a dynamic property and this message will be made for you.
dynamic var coordinate: CLLocationCoordinate2D
For Swift 2, see the previous version of this answer .
source share