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

# filter(using:)

Evaluates a given predicate against the set’s content and removes from the set those objects for which the predicate returns false.

## Declaration

```swift
func filter(using predicate: NSPredicate)
```

## Parameters

- `predicate`: A predicate.

## Discussion

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

## See Also

### Adding and removing entries

- [add(_:)](foundation/nsmutableset/add(_:).md)
- [remove(_:)](foundation/nsmutableset/remove(_:).md)
- [removeAllObjects()](foundation/nsmutableset/removeallobjects().md)
- [addObjects(from:)](foundation/nsmutableset/addobjects(from:).md)
