<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSControlTextEditingDelegate/control(_:isValidObject:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSControlTextEditingDelegate(im)control:isValidObject:"
  },
  "title" : "control(_:isValidObject:)"
}
-->

# control(_:isValidObject:)

Invoked when the insertion point leaves a cell belonging to the specified control, but before the value of the cell’s object is displayed.

```
@MainActor optional func control(_ control: NSControl, isValidObject obj: Any?) -> Bool
```

## Parameters

`control`

The control whose object value needs to be validated.

`obj`

The object value to validate.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if you want to allow the control to display the specified value; otherwise, <doc://com.apple.documentation/documentation/Swift/false> to reject the value and return the cursor to the control’s cell.

## Discussion

This method gives the delegate the opportunity to validate the contents of the control’s cell (or selected cell). In validating, the delegate should check the value in the `object` parameter and determine if it falls within a permissible range, has required attributes, accords with a given context, and so on. Examples of objects subject to such evaluations are an `NSDate` object that should not represent a future date or a monetary amount (represented by an `NSNumber` object) that exceeds a predetermined limit.

## See Also

[`protocol NSControlTextEditingDelegate`](/documentation/AppKit/NSControlTextEditingDelegate)

A set of optional methods implemented by delegates of [`NSControl`](/documentation/AppKit/NSControl) subclasses to respond to editing actions.



---

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)