Swift and CoreData, problems with relationship (NSSet) - [NSSet intersectsSet:]: set argument is not an NSSet

前端 未结 2 1902
天涯浪人
天涯浪人 2021-02-19 19:16

I\'ve been trying to get my head around adding objects in relationships using CoreData and Swift. I am at a loss, I do not understand why my code does not work. I am trying to a

2条回答
  •  我在风中等你
    2021-02-19 20:13

    If you use the objective C generated NSManagedObject subclasses, they include custom methods for adding a single object - I think these are tried and tested and seem better than what is currently there for swift.

    Theoretically you would just need to just set the new set with whatever new set you created. One option would be:

        var matchobjs = matches.allObjects as [Event]
        matchobjs.append(event)
        matches = NSSet(array: matchobjs)
    

    However the error looks very similar to this post:

    Which to me looks like theres something fishy going on again with many-to-many relationships...

提交回复
热议问题