jsonmodel / jsonmodel

Magical Data Modeling Framework for JSON - allows rapid creation of smart data models. You can use it in your iOS, macOS, watchOS and tvOS apps.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Managed Objects

RobertoBiundo opened this issue · comments

Hello,
I was looking for an easy way of integrating this with CoreData's managedObjects.
The idea is to get some object from a server call and store the result in a database using core data, provided that the objects to be stored are the same as the ones coming from the server (with the exception of some ignored fields or optionals).

Since JSONModel forces us to subclass it. A : JSONModel i can't find a practical way of integrating it with the already existing A : NSManagedObject.

I looked into the examples and couldn't find any of them that did this (maybe i'm wrong).
Any suggestions on how to achieve this with JSONModel ?

JSONModel is not intended to work with CoreData. If you want them to interoperate, you can have two different classes and map between them.

Personally though, I’d suggest seriously considering whether you really want to use CoreData. It sucks. Realm and other similar open source local databases work much better.

We would only like to store a couple of classes in the database, not a big deal for this app so i guess mapping is not that crazy of a solution in this case. I'll try to fork the project later and figure out a way of introducing core data if i have the time.