Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always pre-fill the metadata property info slot #23

Open
helje5 opened this issue Oct 21, 2023 · 0 comments
Open

Always pre-fill the metadata property info slot #23

helje5 opened this issue Oct 21, 2023 · 0 comments

Comments

@helje5
Copy link
Contributor

helje5 commented Oct 21, 2023

Sharing a whole entity hasn't been the best idea. But pre-creating the metadata info slots should always be possible. Of course inverse relationships won't usually be set as that requires the model resolution context.

E.g. this:

@Model class Person: NSManagedObject {
  var firstname : String
  var lastname : String
}

would generate sth like:

static let metadata = [
  ( "firstname", \Person.firstname, nil, nil ),
  ( "lastname", \Person.lastname, nil, nil )
]

(this is actually not true, this specific static type is detected by MM :-), but to illustrate the point).
Instead we should do:

static let metadata = [
  ( "firstname", \Person.firstname, nil, makePropertyDescription(for: \Person.firstname) ),
  ( "lastname", \Person.lastname, nil, makePropertyDescription(for: \Person.firstname) )
]

The prototypes in the metadata are always copied already, before they are added to an entity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant