-
Notifications
You must be signed in to change notification settings - Fork 73
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
Combination with Core Data #51
Comments
Haven't used Core Data in a long, long time, but could something like this work? class Test: NSManagedObject {
@NSManaged var foo: String
static func decode(json: AnyObject) throws -> Self {
let test = self.init()
test.foo = try json => "test"
}
} |
Though perhaps your question was on Core Data-best-practice, and if so, I do not know. |
I think the problem is that you can't just call Any thoughts on another approach? I have a feeling that a curried generic function on |
I am thinking about something like this:
I am not sure if it is good aproach. If the init methods could be place to NSManagedObject extension then I think this would be really great. |
A larger problem with CoreData / reference types, is you usually don't want to create new objects every import, but you want to update the state of the existing objects. This would require a proxy / generic import object probably that would contain the existing set of objects, and look them up via some defined primary key. Also, because decode is a class method there would be no pre-defined way to apply a decode to an instance. I think this may be the end of the line for my Core Data investigation here, but I may take a stab at something. Not sure, but this may be outside of the scope of this project. |
Is it possible to combine this great object mapping library with Core Data? How should swift class look like? Thanks
The text was updated successfully, but these errors were encountered: