Storing Data in Core Data: UIImage
Proceed with caution
Difficulty: Beginner | Easy | Normal | Challenging
You probably shoudn’t be doing this. You probably shouldn’t be doing this.
Core Data can store data, but storing large images like this? Probably you want to use file. But I can see that you **really** want to store UIImage
. In that case, let us strap in and get going.
Prerequisites:
- You will be expected to be aware how to make a Single View Application]in Swift
- You’ll need to know about the basics of Core Data
- Have some knowledge of Core Data Basic testing
Terminology
Core Data: A framework that allows you to manage the model layer objects in your application. Core Data does this by being an object graph management and persistence framework.
The image to store
In Assets.xcassets
I’ve added three Placeholder images.
So…surely I can place this image into core data…right?
This involves adding an image attribute to the core data entity, and give it the type Binary Data
.