Skip to content

Any example with Swift + CoreData integration of Marshal #118

@v2Nitesh

Description

@v2Nitesh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions