Arti
Arti

Reputation: 7772

Core data [NSSet intersectsSet:]: set argument is not an NSSet

I have two tables with relations.

enter image description here

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

Answers (1)

Arti
Arti

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

Related Questions