Creating brands
We are going to manually create some brands, and then you can create something similar for products. First, we are going to set up our CloudKit helper before we add any code.
CloudKit helper
We are going to create a CloudKit helper, which will be used to make calls to the CloudKit database. We will have all of this code in a central location:
- Create a new folder called
CloudKit
. - Then, right-click on the
CloudKit
folder and select New File…. - Select Swift file and name it
CloudKitHelper
, and then hit Save. - First, after the
import
statement, add the following:import CloudKit
Next, let's get started by adding a few variables we will need.
- Add the following struct after the
import
statement:struct CloudKitHelper { // Databases static let publicDB = CKContainer.shared. publicCloudDatabase // (1) // Add next step here }