<!--
{
  "availability" : [
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSLogicalTest",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSLogicalTest"
  },
  "title" : "NSLogicalTest"
}
-->

# NSLogicalTest

The logical combination of one or more specifier tests.

```
class NSLogicalTest
```

## Overview

Instances of this class perform logical operations of `AND`, `OR`, and `NOT` on Boolean expressions represented by [`NSSpecifierTest`](/documentation/Foundation/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`](/documentation/Foundation/NSSpecifierTest) objects. [`isTrue()`](/documentation/Foundation/NSScriptWhoseTest/isTrue())—inherited from [`NSScriptWhoseTest`](/documentation/Foundation/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()`](/documentation/Foundation/NSScriptWhoseTest/isTrue()) method.

You don’t normally subclass `NSLogicalTest`.

## Topics

### Initializing a logical test

[`-  initAndTestWithTests:`](/documentation/Foundation/NSLogicalTest/init(andTestWith:))

Returns an `NSLogicalTest` object initialized to perform an `AND` operation with the `NSSpecifierTest` objects in a given array.

[`-  initNotTestWithTest:`](/documentation/Foundation/NSLogicalTest/init(notTestWith:))

Returns an `NSLogicalTest` object initialized to perform a `NOT` operation on the given `NSScriptWhoseTest` object.

[`-  initOrTestWithTests:`](/documentation/Foundation/NSLogicalTest/init(orTestWith:))

Returns an `NSLogicalTest` object initialized to perform an `OR` operation with the `NSSpecifierTest` objects in a given array.

## Relationships

### Inherits From

[`NSScriptWhoseTest`](/documentation/Foundation/NSScriptWhoseTest)

### Conforms To

[`NSCoding`](/documentation/Foundation/NSCoding)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Equatable`](/documentation/Swift/Equatable)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`CVarArg`](/documentation/Swift/CVarArg)

[`Hashable`](/documentation/Swift/Hashable)

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)