我有两个带有关系的表。

在尝试保存产品的ShopItem类中:
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 -它是来自服务器的json响应。
并得到一个错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSSet intersectsSet:]: set argument is not an NSSet' 发布于 2015-10-09 23:59:06
我通过将@objc(Product)添加到我的类中解决了这个问题。
@objc(Product)
class Product: NSManagedObject {
...
}有人能解释一下这是什么意思吗?
https://stackoverflow.com/questions/33037346
复制相似问题