How to receive an image from cloudkit?

Just read the CKRecord that you wrote and you can get the CKAsset by reading the key Image. You can get a UIImage using the code below.

var file : CKAsset? = record.objectForKey("Image")

func image() -> UIImage? {
    if let file = file {
        if let data = NSData(contentsOfURL: file.fileURL) {
            return UIImage(data: data)
        }
    }
    return nil
}

After downloading the CKAsset, we need to convert the CKAsset to a UIImage. We can use the following extension (Swift 4 code):

extension CKAsset {
    func toUIImage() -> UIImage? {
        if let data = NSData(contentsOf: self.fileURL) {
            return UIImage(data: data as Data)
        }
        return nil
    }
}

You have to first have a way of finding the specific ImageRecord that you want to retrieve. Assuming that you have the RecordID for the ImageRecord you saved (you can get this from the record in the saveRecord completion block) you can do:

if let database = privateDatabase {
    database.fetchRecordWithID(recordID, completionHandler: { (record, error) -> Void in
        guard let record = record else {
            print("Error retrieving record", error)
            return
        }

        guard let asset = record["Image"] as? CKAsset else {
            print("Image missing from record")
            return
        }

        guard let imageData = NSData(contentsOfURL: asset.fileURL) else {
            print("Invalid Image")
            return
        }

        let image = UIImage(data: imageData)
        imageView.image = image
    })
}

(Although you would definitely want to be doing some error handling where those print()s are)

If you don't save the recordID (or probably better: the recordID.recordName so you can make another CKRecordID later), you would need some other way of finding which record you are looking for. If that's the case you'd want to look into using CKDatabase's performQuery(_:inZoneWithID:completionHandler:) method.