ioscloudkitckrecordckasset

Are there issues with an array of CKAssets in a single CKRecord?


The app I'm writing will let people store several photos, and associate them with a single object.

I thought I would use CloudKit, to store these images, as CKAssets.

In CloudKit, besides the other property-list types, I can create a CKAsset, and attach a file to it (in my case, a JPEG). I can also attach an NSArray of any of these types, including a CKAsset.

My users might send up 5 images per object, or it may be 30... who knows.

Just wondering if someone has come across a situation like this, and seen drawbacks to this approach. (vs, say, creating separate CKRecords for each image, and adding a reference to another CKRecord, for instance).


Solution

  • Fetching a CKRecord with multiple CKAssets could take considerable time to download. You would not have any control over it. If you store each assets in it's own CKRecord with a CKReference to it's parent record, then you could query those and you would be able to see them coming in one by one. Besides that, are you sure that you always need all the CKAssets when accessing the main record? If not, then it would be a waste of bandwidth. I would advice a separate record for each asset. Then you could also add an assetType field so that you could distinguish the assets if you need to.