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

getResourceValue(_:forKey:)

Returns the value of the resource property for the specified key. 指定されたキーに対するリソースプロパティの値を返します。

Declaration 宣言

func getResourceValue(_ value: AutoreleasingUnsafeMutablePointer<AnyObject?>, 
               forKey key: URLResourceKey) throws

Parameters パラメータ

value

The location where the value for the resource property identified by key should be stored. keyによって識別されるリソースプロパティに対する値が格納されるべき場所。

key

The name of one of the URL’s resource properties. URLの持つリソースプロパティの1つの名前。

error

The error that occurred if the resource value could not be retrieved. This parameter is optional. If you are not interested in receiving error information, you can pass nil. リソース値が回収されることができなかった場合に発生したエラー。このパラメータは随意です。あなたが受け取っているエラー情報に興味がないならば、あなたはnilを渡すことができます。

Return Value 戻り値

true if value is successfully populated; otherwise, false. true、もしvalueがうまく収められたならば、そうでなければfalse

Discussion 議論

This method first checks if the URL object already caches the resource value. If so, it returns the cached resource value to the caller. If not, then this method synchronously obtains the resource value from the backing store, adds the resource value to the URL object's cache, and returns the resource value to the caller. このメソッドは最初にURLオブジェクトが今までにリソース値をキャッシュするか調べます。もしそうならば、それはキャッシュされたリソース値を呼出し側に返します。そうでないならば、その時このメソッドは同期的にリソース値をバッキングストアから入手して、リソース値をURLオブジェクトの持つキャッシュに加えて、そしてそのリソース値を呼出し側に返します。

The type of the returned resource value varies by resource property; for details, see the documentation for the key you want to access. 返されるリソース値の型は、リソースプロパティによって様々です;詳細は、あなたがアクセスを望むキーに対する文書化を見てください。

If this method returns true and the value is populated with nil, it means that the resource property is not available for the specified resource, and that no errors occurred when determining that the resource property was unavailable. このメソッドがtrueを返してその値にはnilが収められるならば、それはそのリソースプロパティがこの指定されたリソースにとって利用可能でないこと、そしてリソースプロパティが利用可能でなかったことを見極めている時にエラーが発生しなかったことを意味します。

If this method returns false, an error occurred. The object pointer referenced by error is populated with additional information. このメソッドがfalseを返すならば、あるエラーが発生しました。errorによって参照されるオブジェクトポインタには、追加情報が入れられます。

See Also 参照

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

Related Documentation 関連文書