---
title: "filtered(using:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/nsset/filtered(using:)"
---

# filtered(using:)

Evaluates a given predicate against each object in the receiving set and returns a new set containing the objects for which the predicate returns true.

## Declaration

```swift
func filtered(using predicate: NSPredicate) -> Set<AnyHashable>
```

## Parameters

- `predicate`: A predicate.

## Return Value

Return Value A new set containing the objects in the receiving set for which predicate returns true.

## Discussion

Discussion The following example illustrates the use of this method. NSSet *sourceSet =     [NSSet setWithObjects:@"One", @"Two", @"Three", @"Four", nil]; NSPredicate *predicate =     [NSPredicate predicateWithFormat:@"SELF beginswith 'T'"]; NSSet *filteredSet =     [sourceSet filteredSetUsingPredicate:predicate]; // filteredSet contains (Two, Three)

## See Also

### Accessing Set Members

- [allObjects](foundation/nsset/allobjects.md)
- [anyObject()](foundation/nsset/anyobject().md)
- [contains(_:)](foundation/nsset/contains(_:).md)
- [member(_:)](foundation/nsset/member(_:).md)
- [objectEnumerator()](foundation/nsset/objectenumerator().md)
- [enumerateObjects(_:)](foundation/nsset/enumerateobjects(_:).md)
- [enumerateObjects(options:using:)](foundation/nsset/enumerateobjects(options:using:).md)
- [objects(passingTest:)](foundation/nsset/objects(passingtest:).md)
- [objects(options:passingTest:)](foundation/nsset/objects(options:passingtest:).md)
