CloudKit - How to share multiple records and retrieve shared records?

后端 未结 2 489
生来不讨喜
生来不讨喜 2021-02-11 04:07

I watched last WWDC 2016 What\'s New with CloudKit to understand how to share records with other users using CKShare

Single record sharing:

2条回答
  •  [愿得一人]
    2021-02-11 05:00

    Regarding question 1, to find the records that have references to the parent, you'll need to create a query that checks the reference field for rootRecordID. This page from Apple has a section discussing retrieval options with code examples.

    https://developer.apple.com/library/content/documentation/DataManagement/Conceptual/CloudKitQuickStart/AddingReferences/AddingReferences.html

    Regarding question 2, you could constantly poll the server for updated records, but Apple discourages that in one of the WWDC videos since it generates a lot of network traffic (and thus burns through your monthly quota). I suggest adding a subscription notice on the CKshare. That way, you'll be notified when you need to fetch records.

提交回复
热议问题