Mac Developer Library

Developer

Foundation Framework Reference NSLogicalTest Class Reference

Options
Deployment Target:

On This Page
Language:

NSLogicalTest

Inheritance


Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.0 and later.

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.

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

    Declaration

    Swift

    init(andTestWithTests subTests: [AnyObject]!)

    Objective-C

    - (instancetype)initAndTestWithTests:(NSArray *)subTests

    Parameters

    subTests

    An array of NSSpecifierTest objects representing Boolean expressions.

    Return Value

    An NSLogicalTest object initialized to perform an AND operation with the NSSpecifierTest objects in subTests.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    init(notTestWithTest subTest: NSScriptWhoseTest!)

    Objective-C

    - (instancetype)initNotTestWithTest:(NSScriptWhoseTest *)subTest

    Parameters

    subTest

    The NSScriptWhoseTest object to invert.

    Return Value

    An NSLogicalTest object initialized to perform a NOT operation on subTest.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    init(orTestWithTests subTests: [AnyObject]!)

    Objective-C

    - (instancetype)initOrTestWithTests:(NSArray *)subTests

    Parameters

    subTests

    An array of NSSpecifierTest objects representing Boolean expressions.

    Return Value

    An NSLogicalTest object initialized to perform an OR operation with the NSSpecifierTest objects in subTests.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.0 and later.