init(importing:)
Initialize a new Ckasset that can be used to create a copy of an asset that already exists in iCloud, potentially in a different container.
Declaration
convenience init(importing exportedAssetID: CKAsset.ExportedAssetID)Parameters
- exportedAssetID:
Identifies the source asset that this Ckasset will copy. The
exportedAssetIDis only valid on the same device it was created, and it expires after a few days.
Discussion
When this asset is saved, a server-side copy of the referenced asset is created.
The new CKAsset does not reference any data on the local device (its fileURL is nil).
When you assign this asset to a field in a CKRecord and save the record, the CloudKit server creates a new asset by copying the contents of the asset identified by the exportedAssetID.
If the source asset no longer exists on the server, saving the record fails with CKError.Code.unknownItem.
If the exportedAssetID is invalid or expired, saving the record fails with CKError.Code.assetNotAvailable.
Assets created this way are supported starting with iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0, and visionOS 1.0. Devices running older OS versions may fail to download the created asset.