Member-only story

Core data allow external storage setting

Codecat15
3 min readJul 12, 2020

--

Usually, we don’t store binary files like images in the databases table for performance reasons and it totally makes sense because the databases may get a little slower when it tries to fetch all that high-resolution image.

So what we developers do is we save the image on the disk and store a reference of that image in the database table.

Now, this is effective, because the queries are faster and you can always pick up the image from the path where you stored it in your document directory folder and display it back on your UI.

But doing this requires manual code, testing, and few hours of development efforts.

What if I told you core data can do this for you and there’s no manual code required to do this

Yes, you heard it right, core data has a setting called “Allow External Storage” for your binary data.

If you have an attribute say profilePicture which stores the profile images of the user then you can just enable this option on the profilePicture attribute of your entity.

Once you enable this setting, the images that you store will NOT be saved in the database table, but they will be saved in a separate folder in the disk which is managed by Core Data.

--

--

Codecat15
Codecat15

Responses (1)