问题
Core Data can store binary data using External Storage if the file is large.
I'm using that External Storage to store images and show them in a UITableView
.
Before, I need to resize theses images to fit the size in the UI.
So, I'm keeping in memory NSData
properties from objects fetched and image resized.
Are there ways to handle this memory issue? or this approach is wrong?
Thanks.
回答1:
You can use NSManagedObjectContext's: - refreshObject:mergeChanges:
passing NO
as the second parameter, this will turn the object back into a fault after you have used the data.
This way, you can get the image, resize it however you want, cache this image and then fault the ManagedObject to give up the data.
来源:https://stackoverflow.com/questions/22454280/how-to-free-memory-using-core-data-external-storage