Beginning CloudKit - Part 4: Saving Records | Ray Wenderlich

In this video, learn all about the basics of saving your data to CloudKit using the convenience API.

This is a companion discussion topic for the original entry at

Hi Brian,

A quick question: What are the advantages of using enums vs. using structs for your constants?

@vegetarianzombie Do you have any feedback on this one? Thank you - much appreciated! :]

Hi Zombie,
No answer yet from Bryan.

Both are umbrellas, both provide type and both help keep your code structured.
But my take on this is that from a semantic point of view , I"ll go for enums.
(It is now the Ray Wenderlich recommended way)
Also using a caseless enum prevents you from creating an instance of that type.

Hey @vegetarianzombie - First, love the tutorials, been extremely helpful. You mention in Saving Data that you will cover modifying a RecordType. I’ve watched a couple of times and can’t find it. I’m using private data to hold a few fields for consistency across devices - I can save the initial values, query them, but can’t figure out how to modify and save. So I have the CRD part of CRUD, looking for the U. Thanks in advance.


Thank you for great tutorial. My question is, how can I save an array of objects, entriesArray in my example :

class FS_Statement

var entriesArray: [FS_Entry] = [ ] //how to save this array?

class FS_Entry
var amount: FS_Amount? //or how would I save this object?

var subEntryArray: [FS_Entry] = [ ]
var type: FinancialEntryType = .parentEntry


class FS_Amount {
var _abs_value: Double?
var _isIncome: Bool?

In Firebase I just made a json dictionary of type AnyObject, but CloudKit doesn’t support it

Hi Brian,
Thank you very much for the great tutorial!

I have a question, Could you please say, can user delete saved data from CloudKit? I tried to delete data from settings, [Settings] -> [iCloud] -> [Manage Storage], but there is not my app in the ‘Manage storage’ list. Also it happened with Key-value storage. Must I do it only programmatically?

I don’t believe user’s have the ability to granularly delete data from cloudkit databases. I’m pretty sure the only option is to opt-out or programmatically delete the info.

1 Like

Hey Brian,
can you explain what happens when the app is closed while records are being saved?

How can I guarantee that the update was successful?

I ask because when I want to save a new value on a record and the internet connection is poor at this moment, the upload might take some time. During this time the user closes the app. What happens then? (it is all asynchronous)

My idea to guarantee it is to store a “successfullySaved” variable that indicates whether the update was successful. I would set it to TRUE in the completion block of the saveRecord function. When the app enters the foreground again, I can check whether there are still updates pending.

Another solution would be long-lived operations. But in my opinion it is a overkill for uploading just one “small” value.

It’s been a long time since I worked with CloudKit. I never did tests to perform a query in the face of app shutdown. If the query is mission critical, then you should have your app perform some background processing. I hope that helps.

Thanks for you reply! Yes I think you are right. it is the best to perform background tasks when working with cloud kit. :slight_smile:

Just a quick bit of feedback. It is super confusing that Brian instructs us to use the AttendeeTableViewController, which is a class in the demo project, but it’s not in the Starter project.

It might be really helpful to just overdub this lesson and correct him to say “SessionTableViewController” instead of “AttendeeTableViewController”. Just sayin’. :wink:

When I get to the challenge, I pause the video. However, it’s only until you get to the solution part of the video does it become clear that at some point the challenge uses SessionTableViewController, not AttendeeTableViewController.

It’s a minor thing, but it’s just a little frustrating – and it held me up a bit, when I’m trying to go through these tutorials as quickly as possible… :+1:t2:

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

Thanks for letting us know. Sometimes these things occur, especially when we do a refactor of an older project. Nice work making it through.

@vegetarianzombie The download materials don’t match what is in the videos.

This are some of the files are missing:

plist files

Can you please let me know here can I download the files are missing?