Member-only story
Storing Data in Core Data: UIImage
Proceed with caution
Difficulty: Beginner | Easy | **Normal** | Challenging
You probably shouldn’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
- Core Basics 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
.
This Binary Data will, fairly obviously, be the data from an image, and for this I can use the…