Instance Method インスタンスメソッド

resourceValues(forKeys:)

Returns a collection of resource values identified by the given resource keys.

Declaration 宣言

func resourceValues(forKeys keys: Set<URLResourceKey>) throws -> URLResourceValues

Parameters パラメータ

keys

A set of URL resource keys indicating the values to retrieve.

Return Value 戻り値

A URLResourceValues instance, containing the retrieved values.

Discussion 議論

This method first checks if the URL instance 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 them to the URL object’s cache, and returns a populated URLResourceValues instance. This method only populates URLResourceValues members corresponding to the contents of the keys parameter.

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

If there’s no available value for a given key in keys, the returned URLResourceValues contains nil for the corresponding item. If this method fails to determine a value’s availability or retrieve its value, the method throws an error.

When you call this method from the main thread, the URL removes cached resource values the next time the thread’s run loop runs, except those added as temporary properties. You can explicitly remove cached resource values with removeCachedResourceValue(forKey:) and removeAllCachedResourceValues().

See Also 参照

Accessing Resource Values リソース値にアクセスする