-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
SwiftUI Cookbook
By :
How can you delete objects from a Core Data repository? Removing objects is almost as important as adding them. In this recipe, we'll learn how to integrate the Core Data delete options into a SwiftUI app.
Let's create a SwiftUI app called DeleteContactsApp, ensuring that we check the Use Core Data checkbox, as shown in the following screenshot:
Figure 11.13 – Creating a SwiftUI app with Core Data
We are going to reuse part of the code provided in the Showing Core Data objects with @FetchRequest recipe. Please refer to that recipe if you want to find out more.
Let's get started:
DeleteContactsApp.xcdatamodeld file and do the following:a. Add a new entity called Contact (1)
b. Add three string attributes called firstName, lastName, and phoneNumber (2)
c. Check that Codegen...