Instance Method

resourceValues(forKeys:)

Returns the resource values for the properties identified by specified array of keys.

Declaration

func resourceValues(forKeys keys: [URLResourceKey]) throws -> [URLResourceKey : Any]

Parameters

keys

An array of property keys for the desired resource properties.

error

The error that occurred if one or more resource values could not be retrieved. This parameter is optional. If you are not interested in receiving error information, you can pass nil.

Return Value

A dictionary of resource values indexed by key.

Discussion

This method first checks if the URL object already caches the specified resource values. If so, it returns the cached resource values to the caller. If not, then this method synchronously obtains the resource values from the backing store, adds the resource values to the URL object's cache, and returns the resource values to the caller.

The type of the returned resource value varies by resource property; for details, see the documentation for the key you want to access.

If the result dictionary does not contain a resource value for one or more of the requested resource keys, it means those resource properties are not available for the URL, and no errors occurred when determining those resource properties were not available.

If an error occurs, this method returns nil 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.