Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete object in NSSet relationship

Tags:

ios

core-data

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?

like image 402
William Falcon Avatar asked Jan 15 '13 19:01

William Falcon


People also ask

How do I delete an object in Nsset?

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:.

How to Delete all Data in Coredata?

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.

How to Delete from Core Data swift?

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.


1 Answers

If car.mySet is your set, you can try it as,

NSMutableSet *mutableSet = [car.mySet mutableCopy];
[mutableSet removeObject:carpartsObject];
car.mySet = [mutableSet copy];
like image 57
iDev Avatar answered Sep 30 '22 19:09

iDev