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(wi
I save JSON by converting it in into Data and save that Data in CoreData
Following Code works for me......
func saveSpotsLocation(model: SpotsModel, packageId: String, regionName: String) {
let newUser = NSEntityDescription.insertNewObject(forEntityName: "SpotsDetail", into: context)
do {
let data = NSKeyedArchiver.archivedData(withRootObject: model.dictionaryRepresentation())
newUser.setValue(data, forKey: "data")
newUser.setValue(packageId, forKey: "packageId")
newUser.setValue(regionName, forKey: "regionName")
try context.save()
} catch {
print("failure")
}
}