Can Core Data lazy-fetch a BLOB attribute on iOS?
I'm storing a photo as a Transformable attribute in my Core Data entity, which is a lot of data to load in an iPhone's memory. If I want to present a TableView that lists all of the entities (potentially hundreds or thousands), but only need to display their title, will Core Data still fetch each photo and store it in RAM before it's needed?
What I want to do is have it "lazy-fetch" the photo only when the user selects a re开发者_运维问答cord to view in another ViewController. What's the most memory-efficient way to do this?
Found the answer myself after a bit more RTFM. In short: no. If you want to store photos in a Core Data model then it's best to create a separate entity type for photos with a 1-to-1 relationship to the main entity. The built-in faulting behavior will lazy-fetch the photo entity only when you actually demand it in your code.
Documented here: http://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdPerformance.html#//apple_ref/doc/uid/TP40003468-SW5
精彩评论