I had a class like this:
class ObjectA:ObservableObject {
@Published var type:ObjectSheetType = .none
}
and I was using a class like this to process instances of this kind of object:
class ProcessObject {
@ObservedObject private var object:ObjectA
init(object:ObjectA) {
self.object = object
}
process() {
if object.type == .big {
// bla bla
}
...
}
Then I have decided to add another class:
class ObjectB:ObservableObject {
@Published var type:ObjectSheetType = .none
}
and a protocol
protocol ObjectProtocol {
var type:ObjectSheetType { get set }
}
This protocol was added to both classes: ObjectA
and ObjectB
.
Then the class ProcessObject
was modified to accept objects of both kinds:
class processObject<T:ObjectProtocol, ObservableObject > {
@ObservedObject private var object:T
init(object:T) {
self.object = object
}
Error: Referencing subscript 'subscript(dynamicMember:)' requires wrapper 'ObservedObject.Wrapper' Insert '$' Value of type 'T' has no dynamic member 'object' using key path from root type 'T'
error pointing to
if object.type == .big {
but also Xcode wants me to use $ in front of every published properties of object
?
How do I solve this?