---
title: "textShouldEndEditing(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsmatrix/textshouldendediting(_:)"
---

# textShouldEndEditing(_:)

Requests permission to end editing.

## Declaration

```swift
func textShouldEndEditing(_ textObject: NSText) -> Bool
```

## Parameters

- `textObject`: The text object requesting permission to end editing.

## Return Value

Return Value true if the text object should proceed to finish editing and resign first responder status. If the delegate returns false, the text object selects all of its text and remains the first responder.

## Discussion

Discussion The NSMatrix method returns false if the text field contains invalid contents; otherwise it returns the value passed back from control(_:textShouldEndEditing:). This method is invoked to let the NSTextField respond to impending loss of first-responder status. This method’s default behavior checks the text field for validity; providing that the field contents are deemed valid, and providing that the delegate responds, control(_:textShouldEndEditing:) is sent to the receiver’s delegate (passing the receiver and textObject as parameters).

## See Also

### Related Documentation

- [delegate](appkit/nsmatrix/delegate.md)

### Editing Text in Cells

- [selectText(_:)](appkit/nsmatrix/selecttext(_:).md)
- [selectText(atRow:column:)](appkit/nsmatrix/selecttext(atrow:column:).md)
- [textShouldBeginEditing(_:)](appkit/nsmatrix/textshouldbeginediting(_:).md)
- [textDidBeginEditing(_:)](appkit/nsmatrix/textdidbeginediting(_:).md)
- [textDidChange(_:)](appkit/nsmatrix/textdidchange(_:).md)
- [textDidEndEditing(_:)](appkit/nsmatrix/textdidendediting(_:).md)
