I have an object Car.h. Car.h has carparts.h (NSSet to relationship).
I need to delete one of the parts in the NSSet belonging to car.h object.
How do I do this?
These are analogous to the NSMutableSet method addObject:. -remove<Key>Object: or -remove<Key>: . At least one of these methods must be implemented. These are analogous to the NSMutableSet method removeObject:.
Delete Everything (Delete All Objects, Reset Core Data) One approach to delete everything and reset Core Data is to destroy the persistent store. Deleting and re-creating the persistent store will delete all objects in Core Data.
Table views have a built-in swipe to delete mechanic that we can draw upon to let users delete commits in our app. Helpfully, managed object context has a matching delete() method that will delete any object regardless of its type or location in the object graph.
If car.mySet
is your set, you can try it as,
NSMutableSet *mutableSet = [car.mySet mutableCopy];
[mutableSet removeObject:carpartsObject];
car.mySet = [mutableSet copy];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With