---
title: "removeCachedResourceValue(forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsurl/removecachedresourcevalue(forkey:)"
---

# removeCachedResourceValue(forKey:)

Removes the cached resource value identified by a given key from the URL object.

## Declaration

```swift
func removeCachedResourceValue(forKey key: URLResourceKey)
```

## Parameters

- `key`: The resource value key whose cached values you want to remove.

## Discussion

Discussion Removing a cached resource value may remove other cached resource values because some resource values are cached as a set of values, and because some resource values depend on other resource values. (Temporary resource values have no dependencies.) This method is currently applicable only to URLs for file system resources. note: The caching behavior of the NSURL and CFURL APIs differ. For NSURL, all cached values (not temporary values) are automatically removed after each pass through the run loop. You only need to call the removeCachedResourceValue(forKey:) method when you want to clear the cache within a single execution of the run loop. The CFURL functions, on the other hand, do not automatically clear cached resource values. The client has complete control over the cache lifetimes, and you must use CFURLClearResourcePropertyCacheForKey(_:_:) or CFURLClearResourcePropertyCache(_:) to clear cached resource values.

## 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)
- [setResourceValues(_:)](foundation/nsurl/setresourcevalues(_:).md)
- [removeAllCachedResourceValues()](foundation/nsurl/removeallcachedresourcevalues().md)
- [setTemporaryResourceValue(_:forKey:)](foundation/nsurl/settemporaryresourcevalue(_:forkey:).md)
- [URLResourceKey](foundation/urlresourcekey.md)
