Hi I am currently trying to building a reader app for the iphone, a bit like NYTimes iphone app or Time magazine or USA today iphone app. Basically I’ll be parsing a feed containing articles, saving the data locally in a database and displaying stuff and all that.
Now I am just starting off with Iphone app development, I would just like to know what is the best way to manage Images in these sort of apps. Id like to save the images for each article locally. Which is the preferred method for doing so, saving it into a database or saving it to the file system. There are a lot of images and managing them would be easier if i store it in a blob field in the database, but that would affect performance dramatically I guess. Saving it into the filesystem, in the application documents directory would give me better performance but I am wondering how would I manage a large amount of file (Saving it, keeping track of an Image of a particular article, deleting files etc)
From the Core Data Programming Guide:
The idea is to load images lazily, only when they need to appear on screen. This is very important on the device.
Consider how many managed objects will be in memory at once. When the objects are instantiated, if you have the image saved as part of the object, it will be loaded into memory as well and will remain in memory until the object is turned into a fault.
As for the second part of your question on how to ensure that files are removed when managed objects are deleted, register for
NSManagedObjectContextObjectsDidChangeNotificationandNSManagedObjectContextDidSaveNotificationand clean up the files that you can obtain from the objects inNSDeletedObjectsKeyandNSUpdatedObjectsKey.