How to Use SwiftData in UIKit Apps

Simon Ng
AppCoda Tutorials
Published in
8 min readDec 27, 2023

--

In iOS 17, Apple introduced a new framework called SwiftData to replace the Core Data framework. Earlier, we have written an introductory tutorial about SwiftData and showed you how to pair SwiftData with SwiftUI.

While there are numerous learning resources available for using SwiftData with SwiftUI, some readers have mentioned that finding comprehensive guides for integrating SwiftData into UIKit apps can be challenging. In this tutorial, we will delve into the process of leveraging the capabilities of SwiftData within the UIKit framework.

A Quick Introduction about SwiftData

To start off, let’s take a brief tour of the SwiftData framework. It’s important to understand that SwiftData should not be mistaken for a database itself. Instead, it is a framework built upon Core Data, specifically developed to assist developers in effectively managing and interacting with data stored persistently. While the default persistent store utilized by iOS is commonly the SQLite database, it’s worth noting that persistent stores can come in various forms. For instance, Core Data can also be employed to manage data stored in a local file, such as an XML file. This flexibility allows developers to choose the most suitable persistent store for their specific requirements.

Whether you opt for Core Data or the SwiftData framework, both tools aim to simplify the intricacies of the underlying persistent store for developers. Take the SQLite database, for example. With…

--

--

Simon Ng
AppCoda Tutorials

Founder of AppCoda. iOS Developer and Indie Entrepreneur. Love coffee, food and travel. http://www.appcoda.com