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

Figure out whether property initialisers _might_ be possible #14

Closed
helje5 opened this issue Sep 26, 2023 · 1 comment
Closed

Figure out whether property initialisers _might_ be possible #14

helje5 opened this issue Sep 26, 2023 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@helje5
Copy link
Contributor

helje5 commented Sep 26, 2023

@NSManaged doesn't allow this:

@Model class Item: NSManagedObject {
  var date = Date()
}

This complains that the @NSManaged var item must not have initialization expressions.

I don't think a macro can remove the expression, but maybe the property could be shadowed somehow. Which would also potentially help w/ Issue #2 .
I.e. instead of generating:

@NSManaged var date : Date

something more like:

var date = Date() {
  didSet { _date = newValue }
}
@objc(date)
@NSManaged var _date : Date

Potentially possible, not quite sure. That the _date is renamed might pose the biggest issue here.

@helje5 helje5 added enhancement New feature or request help wanted Extra attention is needed labels Sep 26, 2023
@helje5
Copy link
Contributor Author

helje5 commented Sep 29, 2023

Fixed in 0.6.0, initial values are now properly tracked in the metadata and can be picked up by the model generator.

@helje5 helje5 closed this as completed Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant