Instance Method

setResourceValue(_:forKey:)

Sets the URL’s resource property for a given key to a given value.

Declaration

func setResourceValue(_ value: Any?, forKey key: URLResourceKey) throws

Parameters

value

The value for the resource property defined by key.

key

The name of one of the URL’s resource properties.

error

The error that occurred if the resource value could not be set.

Return Value

true if the resource property named key is successfully set to value; otherwise, false.

Discussion

This method synchronously writes the new resource value out to disk. Attempts to set a read-only resource property or to set a resource property that is not supported by the resource are ignored and are not considered errors.

If an error occurs, this method returns false and populates the object pointer referenced by error with additional information.

See Also

Related Symbols

URLResourceKey

Keys that apply to file system URLs.

Volume Resource Keys

Resource keys that apply to volumes.

File Property Keys

Keys that apply to properties of files.

Ubiquitous Item Resource Keys

Keys that describe the iCloud storage state of a file.