Updating managed object core data

posted by | Leave a comment

Another common pitfall is to initialize an NSBatch Delete Request with a collection of It basically comes down to the fact that you’re allowed to only use object IDs for objects of the same entity.It’s too bad that the Apple documentation is not really informative here.Setting up an NSBatch Delete Request is fairly simple.

updating managed object core data-56updating managed object core data-74updating managed object core data-25

We do this by creating a simple extension on let fetch Request: NSFetch Request = NSFetch Request(entity Name: "Content") let batch Delete Request = NSBatch Delete Request(fetch Request: fetch Request) managed Object Context.execute And Merge Changes(using: batch Delete Request)After all, you have to ask yourself whether you can use an NSBatch Delete Request for your deletion.

This is only possible if the source of truth for your user’s data isn’t in the data store.

In all other cases, you’ll need to safeguard your user’s data.

The following error is an example of that: A solution would be to use multiple batch delete requests to manually delete each relationship as well.

However, in this case, it might be easier to go for the regular delete method which does respect validation rules.

Leave a Reply

updating bitdefender