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

Core Data initialization #86

Open
lumo2707 opened this issue Mar 30, 2017 · 1 comment
Open

Core Data initialization #86

lumo2707 opened this issue Mar 30, 2017 · 1 comment

Comments

@lumo2707
Copy link

Can you provide us how to use Genome for core data?
Which protocol/class we have to use?

According to your Readme: NSMappableManagedObject is not avaiable.

@lumo2707 lumo2707 reopened this Mar 31, 2017
@couchdeveloper
Copy link

couchdeveloper commented Apr 3, 2017

I did some experiments with the Core Data extension - but it appears to me that it doesn't work as expected - at least with Swift 3.0 and Swift 3.1.

I came up with a working solution in this fork. It uses a different approach: instead of a base class, it uses a protocol and an extension with default implementations. That way, we do not need to modify the sources for the managed objects which are generated by Xcode. This also fixed an issue in a default implementation of an extension function, which would not properly have the dynamic type Self - but rather always only the type to which it is constrained (NSManagedObject) - leading to not get the proper name for the Entity. Also, there seems to be a bug in the code which does not create a managed object - or I'm missing something, or there is a missing extension which is not included in the sources.

So, I quite radically changed the file CoreData.swift. Once that worked, it turned out that there's an issue with passing the context parameter properly to "children". This required a fix in the underlying dependency Node based on version 1.0, for which I created this fork. (Note: Now, it seems, Node v2 will fix this - which is alpha or even beta).

Once that has been fixed, the Genome project needed to be made compatible for Carthage again. I also found a fix for this, but requires Swift 3.1. (This has something to do with how and where SwiftPM stores its build products, and the project uses a pre-build script where the path to the build folder is used).

Now, the Genome project can be used from Carthage as usual (but requires Swift 3.1) and the serialisation of managed objects variables within managed objects to and from JSON now feels much more easier, too.

Before making a PR to Genome, I would like to test it with my team-mates in our projects. Maybe, Node 2 will be available soon and then things may change again dramatically.

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