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

Using existing CoreData objects with convenience initializers #511

Open
bertayyonel95 opened this issue Nov 4, 2024 · 1 comment
Open

Comments

@bertayyonel95
Copy link

bertayyonel95 commented Nov 4, 2024

In the app that I'm working on I have been previously using CoreData, and now I am migrating all my CoreData logic to CoreStore. I have some convenience initializers for my CoreData objects as such;

convenience init(fromJson json: JSON) {
        self.init()
        self.addData(fromJson: json)
    }

I was wondering if it is possible to use these initializers with create(_ into) ? Since creating the object with those initializers and then using fetchExisting on the transaction doesn't seem to work.

@JohnEstropia
Copy link
Owner

Unlike Core Data, CoreStore doesn't allow orphaned objects that do not belong to any store. Instead I would suggest to use the Importing API using ImportableObject or ImportableUniqueObject protocols and use the transaction.import***(...) methods instead.

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

2 participants