I can't wrap my mind around the following: How do I best implement parsing JSON into CoreData?
I already know how to parse JSON and de-serialize it, but how do I get the result into CoreData?
At the moment I have a LoginViewController
that sends a NSURLRequest
with username & pw to a webserver and receives an echo, which is a JSON-file.
And I already have set up the AppDelegate.h
& AppDelegate.m
with the CoreDataStack
My Question: How do I get the NSDictionary (JSON-result) from the LoginViewController
into the database? Do I have to call a method in the app delegate? Or should I place CoreDataStack in LoginViewController
?
Alex, try using Restkit, its really efficient in persisting JSON response directly to Core Data
Use the URL request to fetch the JSON, it maps the entire response to Core Data. You can even modify the payload before persisting.
Communication is internally handled with the help of widely used AFNetworking
A little initial configuration that is required, but the results are worth the effort!