Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
kazihuque2
2,390 PointsShould I load all pertinent data into Model during app initialization? Or use lazy loading to only load data when needed
I am developing an app which will have numerous user and product information. When I used to develop for desktop or web platforms, I would load all the pertinent data from the database into the model during application initialization. In other words, when the application would load, it will populate the entire Model hierarchy with data from the database. This required more memory but that wasn't an issue on the desktop and web platforms as much. My question is in the iOS platform, should I load only those data that will be presented in the view at any one time to manage memory? Or should I load all the data during app opening and hold the data in memory. Also, I am assuming the data will be loaded at the Model level. Is there any best practice regarding how database data can be loaded into a Model in iOS? Should I make a database call inside init or is there a better way?