Implementing a CoreLocation wrapper as @ObservedObject
We mentioned in the introduction to this chapter that @State is used when the state variable has value-type semantics. This is because any mutation of the property creates a new copy of the variable. But what about a property with reference semantics?In this case, any mutation of the variable is applied to the variable itself and SwiftUI cannot detect the variation by itself. We must use a different property wrapper, @ObservedObject, and the observed object must conform to the ObservableObject protocol. Furthermore, the properties of this object that will be observed in the view must be decorated with @Published property wrapper. With this property wrapper, when the properties mutate, the view will be notified, and the body of the view will be rendered again.This will also help, if we want to bridge iOS foundation objects to the new SwiftUI model, such as CoreLocation functionalities. CoreLocation is the iOS framework that determines...