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

Any example with Swift + CoreData integration of Marshal #118

Open
v2Nitesh opened this issue Aug 4, 2017 · 3 comments
Open

Any example with Swift + CoreData integration of Marshal #118

v2Nitesh opened this issue Aug 4, 2017 · 3 comments

Comments

@v2Nitesh
Copy link

v2Nitesh commented Aug 4, 2017

Hi,

Is there any demo for swift + core data with Marshal.

Please suggest the way to integrate core data with marshal.

I have used like below but getting errors.

//
// People+CoreDataClass.swift

//
// Created by Nitesh Meshram on 8/4/17.

//

import Foundation
import CoreData
import Marshal

@objc(People)
public class People: NSManagedObject {

}

extension People: UnmarshalUpdatingWithContext {
mutating func update(object: MarshaledObject, inContext context: DeserializationContext) throws {
firstName = try object.value(for: "first")
lastName = try object.value(for: "last")
// score = try object.value(for: "score")
// address = try object.value(for: "address", inContext: context)
}
}
extension People: UnmarshalingWithContext {
static func value(from object: MarshaledObject, inContext context: DeserializationContext) throws -> People {
var people = context.newPerson()
try people.update(object: object, inContext: context)
return people
}
}

private class DeserializationContext {
func newPeople() -> People {
return People()
}

}

Please suggest.
Thank you

@vatsal1992
Copy link

vatsal1992 commented Oct 18, 2017

An example would be very helpful to understand this fantastic library.

i'm requesting to author, to give a demo project.

@v2Nitesh
Copy link
Author

@vatsal1992 - you want me to prepare demo?? I am facing issues with Marshal+Core Data

@scottandrew
Copy link

There is no one to one integration.. What we did was to just create the managed object and have extension functions to unmarshal the values since you can not directly allocate an core data model without the context.

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

3 participants