---
title: NSLogicalTest
framework: foundation
role: symbol
role_heading: Class
path: foundation/nslogicaltest
---

# NSLogicalTest

The logical combination of one or more specifier tests.

## Declaration

```swift
class NSLogicalTest
```

## Overview

Overview Instances of this class perform logical operations of AND, OR, and NOT on Boolean expressions represented by NSSpecifierTest objects. These operators are equivalent to “&&”, “||”, and “!” in the C language. For AND and OR operations, an NSLogicalTest object is typically initialized with an array containing two or more NSSpecifierTest objects. isTrue()—inherited from NSScriptWhoseTest—evaluates the array in a manner appropriate to the logical operation. For NOT operations, an NSLogicalTest object is initialized with only one NSSpecifierTest object; it simply reverses the Boolean outcome of the isTrue() method. You don’t normally subclass NSLogicalTest.

## Topics

### Initializing a logical test

- [init(andTestWith:)](foundation/nslogicaltest/init(andtestwith:).md)
- [init(notTestWith:)](foundation/nslogicaltest/init(nottestwith:).md)
- [init(orTestWith:)](foundation/nslogicaltest/init(ortestwith:).md)

### Initializers

- [init(andTestWithTests:)](foundation/nslogicaltest/init(andtestwithtests:).md)
- [init(notTestWithTest:)](foundation/nslogicaltest/init(nottestwithtest:).md)
- [init(orTestWithTests:)](foundation/nslogicaltest/init(ortestwithtests:).md)

## Relationships

### Inherits From

- [NSScriptWhoseTest](foundation/nsscriptwhosetest.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Object Matching Tests

- [NSScriptWhoseTest](foundation/nsscriptwhosetest.md)
- [NSSpecifierTest](foundation/nsspecifiertest.md)
