I have a relationship Order<-->>Row with both relationship delete rules set to Nullify. But when I delete a row as below, it is not removed from the Order’s row-list?
// Prints "1" as there is one row in the order
NSLog(@"Number of children before: %d", order.rows.count);
for (Row *row in order.rows)
[moc deleteObject:row];
// Prints "1", should be "0"
NSLog(@"Number of children after: %d", order.rows.count);
This can force the behavior, but it shouldn’t be needed. What might be wrong?
for (Row *row in order.rows)
{
[moc deleteObject:row];
[order removeRowsObject:row];
}
That’s not what nullify does. Use cascade instead. I answered a similar question to this 2 days ago, look at it if you need more detail: Deleting (updating) coreData objects