Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS

Kieran Robinson
Kieran Robinson
9,411 Points

Speeding up Core Data Stored images

Hi guys, I am displaying images in UITableViewCells (one large image plus a button that shows 2 more images in a scroll view). The images are all stored in core data (stored as binary data, with both 'allows external storage' and 'store in external record file') as i followed the Core Data course with Ash Furrow to achieve this. However when the table grows to 100+ cells, the UI is very slow and unresponsive and also seems to load the images one by one (when i scroll, it freezes before every image is displayed). Any help regarding speeding up the process of loading images from core data is much appreciated, kieran

2 Answers

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Core Data performance is nuanced and depends on many variables. You should watch this video on Core Data Performance Optimization. One quick fix is to set the fetchBatchSize property of your NSFetchRequest to a low number like 10 or 20. The other thing you might want do is store a thumbnail image so you are not loading big images in a table view cells. Hope that helps. I would highly recommend watching that video because it has really good insights.

Kieran Robinson
Kieran Robinson
9,411 Points

Thanks a lot Amit Bijlani, I will watch the video now and i've already implemented the batchSize to 10, which has sped up the app massively. Thanks again!