mirror of
https://github.com/JohnEstropia/CoreStore.git
synced 2026-01-12 04:10:36 +01:00
Updating existing set of relationships issue #270
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @matrosovDev on GitHub (Apr 30, 2019).
Hi could someone help or explain where I did mistake
I try to update workout.muscles Swift.Set which is a relationship One Workout To Many Muscles.
For the first call all works good, but all next calls just add only new inserted object to fetchExisting others seems are stored in some background context.
Here is a link to question:
https://stackoverflow.com/questions/55921312/corestore-insert-array-as-relationship-objects-while-updating-data-model
@JohnEstropia commented on GitHub (May 1, 2019):
Hi, this would be the general behavior of
NSManagedObjects with regards to to-many properties.First, as you have found out, the inverse relationship is important.
Second,
Setis not recommended for unordered@NSManagedproperties. Please useNSSet.In that note, it should be treated as immutable. Which means you cannot insert objects directly to the
NSSetvalue. There are two ways you can insert values.NSSetdirectly:NSMutableSetproxy for you):@matrosovDev commented on GitHub (May 2, 2019):
As John suggested we need to declare properties as NSSet instead Set and then we can use 2 code fragments above to make it done.
Answered here as well:
https://stackoverflow.com/questions/55921312/corestore-insert-array-as-relationship-objects-while-updating-data-model