Search code examples
swiftcloudkit

Cloud Kit - Synching image


I'm currently sharing data between devices using core data and cloud kit.

Currently I have a "Picture" entity which stores the filename, the date it was added and a relation to another entity.

The details in core data successfully syncs, how would I go about syncing the image file. The file is saved in the documents folder and I can get its file path using

let imagePath = (NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString).appendingPathComponent(imageName)

Research seems to show I need to use CKAsset to upload/download the file but how do I go about doing this?


Solution

  • Resolved the issue by saving the image as data into core data, can then convert it back to an image when displaying