In CoreData, I have defined an unordered to-many relationship from Node
to Tag
. I've created an Swift entity like this:
import CoreData
class Node : NSManagedObject {
@NSManaged var tags : Array<Tag>
}
Now I want to add a Tag
to an instance of Node
, like this:
var node = NSEntityDescription.insertNewObjectForEntityForName("Node", inManagedObjectContext: managedObjectContext) as Node
node.tags.append(tag)
However, this fails with the following error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Unacceptable type of value for to-many relationship: property = "tags"; desired type = NSSet; given type = _TtCSs22ContiguousArrayStorage000000000B3440D4; value = ( "<_TtC8MotorNav3Tag: 0xb3437b0> (entity: Tag; id: 0xb343800 ; data: {...})" ).'
What is the correct type for to-many relationships?
Foundation
. – Bouke