CloudKit Tutorial: Getting Started | raywenderlich.com

In this CloudKit tutorial, you’ll learn how to add and query data in iCloud from your app, as well as how to manage that data using the CloudKit dashboard.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4878052-cloudkit-tutorial-getting-started

Wonderful tutorial! I’m learning a ton from it, beyond just the cloudkit portion. The sample code is great.

The one topic that I can follow in the code, but wouldn’t have there on my own, is the ‘Model’ class.

Can you help me understand the rationale for it? Is it effectively always best practice to structure things this way when interacting with CloudKit data? Any articles or tutorials on the subject that would be good to read up on (searching hasn’t turned up much!).

Thanks :slight_smile:
Steve

I have an issue running the app. My app won’t load a list of places from the database. Looks like the constructor for the Establishment class isn’t actually parsing the CKRecord it’s being passed.

Why is “results” assigned the type “[weak self]” and not “CKRecord”?

I think I’m getting my head around the Model (Apple recommendation to wrap the CK interactions, by the looks of it) - but now I’m starting to play with adding notes to the app.

I’ve gotten to the point of creating a new note, and even populating the Establishment Record ID for that Note - but haven’t cracked how to also append the new Note recordName to the Establishment’s Reference (List) and am struggling to find examples. Any ideas @mkatz? :slight_smile:

Great Tutorial! Would love to referenced the video series updated to latest Xcode and Cloudkit
https://www.raywenderlich.com/3413-introduction-to-cloudkit/lessons/1

@keydogg Please check out the updated version of the course over here:

https://www.raywenderlich.com/4247-beginning-cloudkit

I hope it helps!

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

Hey @mechaamir, sorry for the delay, but for future reference on your question:
In Swift, this is actually a capture list, not typing the results to be CKRecord. Whenever you assign a closure to a property, and self is referenced in that closure, you actually create a strong reference cycle, and could have a memory leak. This allows values to be set to nil that might have been otherwise captured in the closure.

Does the issue still occur with the finished project for you?

Once you create a Note, you’ll need to add the CKRecord.Reference of that note to the array of notes on Establishment. The true would be the same for the inverse: you need to add the Establishment’s CKRecord.Reference to the Note’s establishment field.

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!