| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This buildable (and testable) Xcode project demonstrates a simple use of the CloudKit Private Database. It allows you easily try out reading from and writing to a Private Database for a user in your own container on CloudKit servers.
An Apple Developer Program membership is needed to create a CloudKit container.
A Mac with Xcode 12 (or later) installed is required to build and test this project.
Upon launch, the app reads a single record from the CloudKit server.
Specifically, this record resides in the Default Zone of the currently signed-in iCloud user's Private Database in the app's CloudKit Container.
The record is of type "Person". The "Person" record type, as defined in the CloudKit Container's Schema by the app's developer, has a single custom string field called "name".
The specific CloudKit record the app reads has a well-known record ID of "lastPerson". (This well-known ID is hardcoded in the app.)
The app's UI displays the name of the last person to write their name into the "name" field of this record on the server.
When the user of the app enters their own name into a text field in the UI, the app writes the user's name into the "name" field of this same CloudKit Record and saves it back to the CloudKit Server.
Subsequent launches of this app from this device (or other devices) will show this user's name until another user's name is written into the "name" field of the same CloudKit Record.
A working Xcode project that interacts with the CloudKit server
Some basic data flows between CloudKit and a SwiftUI View
Reading from and writing to a CloudKit Private Database
Writing a CloudKit record using CKModifyRecordsOperation
Overriding the default savePolicy when writing
Fetching an explicit record by ID using the fetch(withRecordID:) convenience method on CKDatabase
Some basic error trapping of CKError errors, including those embedded in partialFailure
Some basic testing using XCTest
| Back | FazBrowse Home | New Git URL |