Contents

init(fileURL:)

Creates an asset that references a file.

Declaration

init(fileURL: URL)

Parameters

  • fileURL:

    The URL of the file that you want to store in CloudKit. You must provide a file URL, and it must not be nil.

Return Value

An asset object that represents the specified file.

Discussion

Use this method to initialize new file-based assets that you want to transfer to iCloud. After saving an asset to the server, CloudKit doesn’t delete the file at the specified URL. If you no longer need the file, you must delete it yourself. When you subsequently download a record that contains an asset, CloudKit downloads its own copy of the asset data to the local device and provides you with a URL to that file.

You can assign only one record to the asset that this method returns. If you want multiple records to point to the same file, you must create separate assets for each one.