I want to save the JSON Result from web service to Core data, following is the code for JSON parsing.
if let jsonResult = try JSONSerialization.jsonObject(with: JSONData!, options: [.mutableContainers]) as? [String: AnyObject]
If i prints jsonResult, following is the output
["Code": 00, "Desc": success, "iinData": <__NSArrayM 0x1c02531a0>
{
name = “AAA”;
iin = 123456;
isOn = 0;
},
{
name = "Allahabad Bank";
iin = 608112;
isOn = 0;
},
)
I can able to insert Code, Desc into Entity1, but how to insert innData into Entity2 .
Entity1 Structure Entity2 Structure
Following is the code for inserting JSON result into core data
func createEntity1From(dictionary: [String: AnyObject]) -> NSManagedObject? {
let context = CoreDataStack.sharedInstance.persistentContainer.viewContext
if let Entity1 = NSEntityDescription.insertNewObject(forEntityName: “ParamDownload”, into: context) as? ParamDownload {
Entity1.Code= dictionary[“name”] as? String
Entity1.desc = dictionary[“desc”] as? String
return Entity1
}
}