Hi
I've read in several places that the default coredata code produce by xcode, when creating a new project, shouldn't really be in the app delegate file. I'm new to core data and am finding it difficult to make sense of the many contradictory examples I'm finding on the Internet. In some cases, admittedly they are just examples, the data manipulation and retrieval code is also in the app delegate.
Is this correct?
Should custom code in the app delegate be limited to calls to other classes?
What are the pitfalls of putting functionality in the app delegate?
I ask because I shifted the default persistent container and context etc. into a separate class, as when I tried to do a save in the background (using DispatchQueue) I got an error stating something along the line that I couldn't do that against the viewContext as it was part of the app delegate (apologies for not being specific, that was over a week ago).
Foolishly I thought I'd do my learning by building what I thought, based on many years experience with VB etc., was a very simple app. Turns out that nothing is that simple. I've hit so many walls I think that my approach in many places is fundamentally wrong. I don't learn well reading manuals, rather I prefer working examples etc.
If anyone has an example of, or a link to, code that demonstrates correctly how to work with core data with relationships etc. it'd be much appreciated.
In particular how to:
a) not lock up the UI (I have potentially thousands of related records).
b) know when all data for a relationship has been retrieved (I'm getting an error now stating an array populated from NSMutableSet.allObjects mutated while being iterated)
Thanks in advance...
Ps. My code is written in Swift.