1

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).

Dan Morrow
  • 4,433
  • 2
  • 31
  • 45
  • I'm just starting to do something similar. I'll be adding dozens of images via `CKAsset` to a single `CKRecord`. That is what you are supposed to be able to do. – rmaddy May 25 '15 at 02:22
  • Yeah, I mean, I know I **can** do that, I'm just wondering if it's better to create an NSArray, and attach all of these CKAsset files OR if maybe I should create a separate record-type that only contains a CKAsset, and create references to it. These are images, the could be a couple of megabytes each. It can be coded either way. Just wondering if there might be performance / bandwidth / other issues with doing it one way (all images in a record) vs another (each image in a record, referencing a "parent" record). – Dan Morrow May 25 '15 at 02:30
  • I suggest doing it the "proper" way (attach the assets to their record) and see how it goes. Don't look for a problem before one exists. I can only assume Apple was smart about how they made it work. – rmaddy May 25 '15 at 02:35

1 Answers1

6

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.

Edwin Vermeer
  • 13,017
  • 2
  • 34
  • 58