---
title: "setResourceValues(_:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurl/setresourcevalues(_:)"
---

# setResourceValues(_:)

Sets the URL’s resource properties for a given set of keys to a given set of values.

## Declaration

```swift
func setResourceValues(_ keyedValues: [URLResourceKey : Any]) throws
```

## Parameters

- `keyedValues`: A dictionary of resource values to be set.

## Discussion

Discussion This method synchronously writes the new resource value out to disk. If an error occurs after some resource properties have been successfully changed, the userInfo dictionary in the returned error object contains a kCFURLKeysOfUnsetValuesKey key whose value is an array of the resource values that were not successfully set. 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. The order in which the resource values are set is not defined. If you need to guarantee the order in which resource values are set, you should make multiple requests to this method or setResourceValue(_:forKey:). note: This method applies only to URLs for file system resources. note: In Swift, this method returns Void 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

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