---
title: "resourceValues(forKeys:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurl/resourcevalues(forkeys:)"
---

# resourceValues(forKeys:)

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

## Declaration

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

## Parameters

- `keys`: An array of property keys for the desired resource properties.

## Return Value

Return Value A dictionary of resource values indexed by key.

## Discussion

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. note: This method applies only to URLs that represent file system resources. note: In Swift, this method returns a nonoptional result and is marked with the throws keyword to indicate that it throws an error in cases of failure. You call this method in a try expression and handle any errors in the catch clauses of a do statement, as described in Error Handling in The Swift Programming Language and About Imported Cocoa Error Parameters.

## See Also

### Accessing Resource Values

- [getResourceValue(_:forKey:)](foundation/nsurl/getresourcevalue(_:forkey:).md)
- [setResourceValue(_:forKey:)](foundation/nsurl/setresourcevalue(_:forkey:).md)
- [setResourceValues(_:)](foundation/nsurl/setresourcevalues(_:).md)
- [removeAllCachedResourceValues()](foundation/nsurl/removeallcachedresourcevalues().md)
- [removeCachedResourceValue(forKey:)](foundation/nsurl/removecachedresourcevalue(forkey:).md)
- [setTemporaryResourceValue(_:forKey:)](foundation/nsurl/settemporaryresourcevalue(_:forkey:).md)
- [URLResourceKey](foundation/urlresourcekey.md)
