How to free memory using Core Data External Storage?

丶灬走出姿态 提交于 2019-12-13 00:57:42

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!