Reputation: 7772
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'
Upvotes: 3
Views: 2066
Reputation: 7772
I solved problem by adding @objc(Product)
to my class.
@objc(Product)
class Product: NSManagedObject {
...
}
Can anyone explain what does this mean ?
Upvotes: 3