---
title: "value(forKey:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsset/value(forkey:)"
---

# value(forKey:)

Return a set containing the results of invoking valueForKey: on each of the receiving set’s members.

## Declaration

```swift
func value(forKey key: String) -> Any
```

## Parameters

- `key`: The name of one of the properties of the receiving set’s members.

## Return Value

Return Value A set containing the results of invoking valueForKey: (with the argument key) on each of the receiving set’s members.

## Discussion

Discussion The returned set might not have the same number of members as the receiving set. The returned set will not contain any elements corresponding to instances of valueForKey: returning nil (note that this is in contrast with NSArray’s implementation, which may put NSNull values in the arrays it returns).

## See Also

### Comparing Sets

- [isSubset(of:)](foundation/nsset/issubset(of:).md)
- [intersects(_:)](foundation/nsset/intersects(_:).md)
- [isEqual(to:)](foundation/nsset/isequal(to:).md)
- [setValue(_:forKey:)](foundation/nsset/setvalue(_:forkey:).md)
