Observe of CoreStoreObject subclass issue
I try to make observer of the value like described in the documentation:
observer = video.status.observe(options: [.new]) { (video, change) in
but stuck with the error:
Generic parameter 'Value' could not be inferred
Here is my model:
class Video: CoreStoreObject {
@Field.Stored("status")
var status: String = ""
....
}
And it's ok when I refactor my model to xcdatamodel (to use NSManagedObject subclass):
observer = video.observe(\.status, options: [.new]) { (video, change) in
Maybe the documentation is a little out of date?
I can make it works with CoreStoreObject subclass changing this line to:
observer = video.observe(\Video.$status, options: [.new]) { (video, change) in
Since you are using @Field.Store, the syntax requires $ like you have discovered.
The documentation was using examples that used Value.Required and friends, which are not propertyWrappers and thus not need the $ syntax.
Got it. Thanks. I think it would be better to add this case to the documentation, what do you think?