I have two tables with relations.
At ShopItem class trying to save product:
let productEntity = NSEntityDescription.entityForName("Product", inManagedObjectContext: self.managedObjectContext!)
product = Product(entity: productEntity!, insertIntoManagedObjectContext: self.managedObjectContext!)
if let product_title:String = jsonObj["product_title"] as? String {
product.setValue(product_title, forKey: "product_title")
} else {
product.setValue("", forKey: "product_title")
}
product.setValue(self, forKey: "shopitem")
do {
try self.managedObjectContext!.save()
} catch {
fatalError("Failure to save context: \(error)")
}
jsonObj
- it is a json response from server.
And get an error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet'