I dive into iOS programming and use Core Data in my application to save game data, however I wonder if my approach to using Core Data is appropriate. I have three tables in my database, the first two having a one-to-many relationship with another table (for example, "UserProfile →> Puzzle Packs →> Puzzles").
The approach I take to use and save data is simple, get an instance of UserProfile using NSFetchedResultsController and save the UserProfile object as an instance of var in my application delta. Then I use this UserProfile object in the rest of the code to access and change the state of puzzles and puzzles (representing the user's progress in the game), and whenever I make changes to objects, I simply call the NSManagedObjectContext save method to update the database, which is also stored in the application delegate.
My question is, should I retrieve data from the database at any time when I need to access or change it, or my current approach, fetching the top object once and often calling the save method, the correct way to use Core Data?
Thank you for your wisdom! I apologize if my question is odd, I'm still a noob.
source share