ios - Does Core Data autoupdate a many to many relationship on saving -
I have used 2 database tables and core data / NSManagedObjects in SQLite:
User is user_id name group (multiple groups) Group group_id title group members (multiple users)By using core data to save a group and adding users ( Add to group) as follows:
group * cordata = zero; Cordata = [NSEntityDescription insertNewObjectForEntityForName: @ Managed Object Contains in "Groups": Reference]; Request = [NSFetchRequest fetchRequestWithEntityName: @ "user"]; Request.predicate = [NSPredicate predicateWithFormat: @ "user_id =% @", user_id]; Result = [reference executeFetchRequest: request error: & amp; Error]; CoreData.group_id = group_id Cordettitle = Title [Cordata AdGroupMailersObject: [Last objections result]]; Is it right to say that core data manages a user with multiple users and groups with the code above?
Yes, if the relationships are in the form of each other's inverse relationship The inverse relationships are updated automatically by modifying a relationship that is set in.
Note: I will call institutions "user" and "group", because the single user or group I am also (but this Taste can be a matter) Relationships are just called "groups" and "users".
Comments
Post a Comment