Learn Courses My Dashboard

Core Data Images

Who knows how to save a photo in core data in a View Controller and make it available to see in another View Controller?

It is not recommended to save image data to CoreData as it bloats the database unnecessarily. The best method is to save the image to the Documents Folder and then save a reference (filename) to the image in CoreData.

The filename reference would ideally be a UUID()

If you set the allows external storage property on your binary data image attribute, then Core Data will decide whether to store the data in its tables or in the file system, depending on the size of the image involved. And you don’t need to mess around with figuring out the path or anything like that. I’m not sure what the exact threshold is, but I believe it’s around 100 kb or so; anything larger gets stored externally, everything else in the tables.