---
title: "removeObject(forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nscache/removeobject(forkey:)"
---

# removeObject(forKey:)

Removes the value of the specified key in the cache.

## Declaration

```swift
func removeObject(forKey key: KeyType)
```

## Parameters

- `key`: The key identifying the value to be removed.

## See Also

### Adding and Removing Cached Values

- [setObject(_:forKey:)](foundation/nscache/setobject(_:forkey:).md)
- [setObject(_:forKey:cost:)](foundation/nscache/setobject(_:forkey:cost:).md)
- [removeAllObjects()](foundation/nscache/removeallobjects().md)
