cyclingIsBetter
cyclingIsBetter

Reputation: 17591

iOS: delete entity with one to many relationship in core data

In my app I have two entity in this way:

enter image description here

So, I've two questions:

1- when I delete a "First" entity I want to delete all entity "Characteristics" that belong to first. Do I set the delete rule "Cascade"?

2- If I delete a "characteristics" object from figure, with the method

- (void)removeCharacteristicsObject:(Characteristics *)value;

I want to delete also the characteristics identity, not only from figure, what's the way to do it?

thanks

Upvotes: 1

Views: 1777

Answers (1)

Fogmeister
Fogmeister

Reputation: 77661

  1. Correct. Set the delete rule for figure -> characteristic to Cascade. This will delete all the characteristics associated with a figure when you delete the figure.

  2. You don't even need to remove the characteristic. Just delete the characteristic and it will remove it from the figure. You could remove it and then delete it but easier just to delete it. Set the delete rule for characteristic -> figure to Nullify.

Upvotes: 2

Related Questions