I have a simple class conforming to the codable protocol. Here is an example which is the same like in the developer documentation...
class Landmark: Codable {
var name: String
var foundingYear: Int
}
Because the two properties inside the class body are basic Swift types the compiler has nothing to complain.
But if I want to edit these properties using SwiftUI I must also make sure that the class conforms also to the ObservableObject protocol.
class Landmark: Codable, ObservableObject {
@Published var name: String
@Published var foundingYear: Int
}
Now I get an Xcode error message that type Landmark does not conform to the codable protocol anymore.
This is something I cannot understand. The property wrapper @Published should not change the type of the properties String and Int. The codable conformance should imho still be given to the class without additional lines of codes.