Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
EVManagedObject.swift
EVManagedObjectArrayExtension.swift
README.md

README.md

EVReflection/CoreData

This is the sub specification for a CoreData extension for EVReflection

General information

If you have a question and don't want to create an issue, then we can Join the chat at https://gitter.im/evermeer/EVReflection

EVReflection is used in EVCloudKitDao and EVWordPressAPI

In most cases EVReflection is very easy to use. Just take a look at the YouTube tutorial or the section It's easy to use. But if you do want to do non standard specific things, then EVReflection will offer you an extensive range of functionality.

Available extensions

There are extension available for using EVReflection with Realm, XMLDictionairy, CloudKit, Alamofire and Moya with RxSwift or ReactiveSwift

Installation

CocoaPods

pod 'EVReflection/CoreData'

Advanced object mapping

This subspec can use all EVReflection features like property mapping, converters, validators and key cleanup. See EVReflection for more information.

Usage

Create your core data model like you use to do. Then from the menu Editor selec 'Create NSManegedObject subclass...' and generate all objects. In your core data model set for all entities the Class CodeGen to Manual/None then for all your NSManaged subclasses change NSManagedObject into EVManagedObject and import EVReflection

import Foundation
import CoreData
import EVReflection

@objc(CoreDataPerson)
public class CoreDataPerson: EVManagedObject {
}

Then creating an instance in your database based on a json string will work like this:

let moc: NSManagedObjectContext = EVReflectionTestsData().moc // Your code for getting the NSManagedObjectContext.

let obj = CoreDataPerson(context: moc, json: "{\"firstName\" : \"Edwin\", \"lastName\" : \"Vermeer\"}")

try! moc.save() //You should implement error handling

Parsing an object array is just as easy:

let moc: NSManagedObjectContext = EVReflectionTestsData().moc // Your code for getting the NSManagedObjectContext.

let arr = [CoreDataPerson](context: moc, json: "[{\"firstName\" : \"Edwin\", \"lastName\" : \"Vermeer\"},{\"firstName\" : \"Edwin 2\", \"lastName\" : \"Vermeer 2\"}]")

try! moc.save() //You should implement error handling
You can’t perform that action at this time.