Offline Persistent Storage in iOS Applications

Shivam Maggu
2 min readDec 21, 2023

In this article, we will discuss the various kinds of persistent storage options provided by Apple for iOS applications.

Table of Contents

- What is offline storage?
- Why do we need it?
- When should we use it?
- How should we use it?

What is offline storage?

It is a kind of storage not on a network but on a physical device. In regards to an iOS application, it means that the data generated or displayed by an app is not stored on or retrieved from a network. Instead, it resides locally in the user’s device.

Why do we need it?

It makes the app more accessible to the users. They are not dependent on the internet to use the app’s functionality.

When should we use it?

Let’s take examples of some popular apps that do not hinder user functionality when offline.

  • Chat apps such as Telegram and WhatsApp can store your messages when offline and deliver them when the connection is restored.
  • Automation apps like Automate store users flow offline.
  • Offline dictionaries store the words and their definitions on the device.
  • E-book reading apps store the books offline so users can read anytime and anywhere.
  • Mail apps like Gmail and Outlook queue your recently sent emails in Outbox and send them once online.
  • Contacts and SMS apps store phone numbers and text messages.
  • OTT apps provide download features to store your favourite TV Shows and Movies locally and watch offline.
  • Todo lists, reminders, calendars, sketching and fitness tracker apps store data offline.
  • YouTube and Spotify can download our favourite songs to local storage.

We should use offline persistent storage when an app calls for such use cases. We can also use offline storage to cache data models fetched from the REST APIs.

How should we use it?

If your app architecture calls for offline storage there are various ways to achieve this in iOS. Mentioned below are some examples provided directly by Apple.

  • UserDefaults
  • KeyChain
  • Property List
  • FileManager
  • URLCache
  • Core Data

I’ll be adding a separate article discussing the features, implementation and use case for each storage technique.

Originally published at https://blog.shivammaggu.com on December 21, 2023.

--

--

Shivam Maggu
0 Followers

iOS developer specializing in swift and anything tech that piques my interest.