Observe of CoreStoreObject subclass issue #344

Open
opened 2025-12-29 18:25:54 +01:00 by adam · 3 comments
Owner

Originally created by @Maxim-Inv on GitHub (Oct 16, 2020).

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

Screenshot 2020-10-16 at 16 13 41

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
Originally created by @Maxim-Inv on GitHub (Oct 16, 2020). 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` <img width="993" alt="Screenshot 2020-10-16 at 16 13 41" src="https://user-images.githubusercontent.com/1230938/96263146-598b2100-0fcb-11eb-9008-a3d95c82a4df.png"> 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 ```
adam added the questionpending docs update labels 2025-12-29 18:25:54 +01:00
Author
Owner

@Maxim-Inv commented on GitHub (Oct 16, 2020):

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
@Maxim-Inv commented on GitHub (Oct 16, 2020): 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 ```
Author
Owner

@JohnEstropia commented on GitHub (Oct 16, 2020):

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.

@JohnEstropia commented on GitHub (Oct 16, 2020): 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.
Author
Owner

@Maxim-Inv commented on GitHub (Oct 16, 2020):

Got it. Thanks.
I think it would be better to add this case to the documentation, what do you think?

@Maxim-Inv commented on GitHub (Oct 16, 2020): Got it. Thanks. I think it would be better to add this case to the documentation, what do you think?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/CoreStore-JohnEstropia#344