Same crash here. iOS 16.6
Post
Replies
Boosts
Views
Activity
I wish I could edit the title! 😅
For indexing purposes, the correct word is:
NSManagedObjectContext
If this is really when you want to save(), I suggest reading up on the lifecycle of an app and using appropriate scene delegate methods if that’s the flow your app used.
Of course, iOS doesn’t ever really tell you if your app has been force-terminated by the user.
Hmm the code is just auto generated boilerplate, maybe include something more substantive and you will get better advice.
You might consider disabling the validation rule and using a batch insert followed by a batch delete of objects that would have broken the rule.
This is impossible to answer without seeing your app. How you interact with the data source and use it to configure the layout of the the collection view and its cells has a large impact on performance.
Million dollar question, what’s certain is that batch requests don’t support relationships.
Look into NSPredicate syntax.
Setting relationships in batch requests is not supported. Check out the WWDC talks from 2019 and 2020.
The documentation states:
Changes are not reflected until after the controller’s managed object context has received a processPendingChanges() message. Therefore, if you change the value of a managed object’s attribute so that its location in a fetched results controller’s results set would change, its index as reported by the controller would typically not change until the end of the current event cycle (when processPendingChanges() is invoked).
Maybe what’s happening is just that. And on the view context pending changes are just processed sooner. You could hook into that method to check.
https://developer.apple.com/documentation/coredata/nsfetchedresultscontroller