I have a core data entity which has an exclusive one to many relationship with another entity. This relationship is supposed to be a basic containment the first entity contains one or more of the second. An instance of the second entity can only be contained in one of the first e开发者_如何转开发ntities.
I want to be able to remove all the contained entities from the first entity and then delete them. How should I do this? Should I remove the relationship and then call deleteObject for each entity or will calling deleteIObject for each contained entity cause the relationship to be set correctly. If the second is true, can I just enumerate the contained entities and call deleteObject or should I first make a copy of the set (if calling deleteObject for each objects severs the relationship this will modify the set which is not allowed in normal enumeration).
Delete each child object via the NSManagedObjectContext
and the relationship will clean up appropriately. This is assuming that you are following the convention and have all of your relationships configured to be bi-directional.
精彩评论