Instance Method


Sent when a text view needs to determine if text in a specified range should be changed.


- (BOOL)textView:(NSTextView *)textView shouldChangeTextInRange:(NSRange)affectedCharRange replacementString:(NSString *)replacementString;



The text view sending the message. This is the first text view in a series shared by a layout manager, not necessarily the text view displaying the selected text.


The range of characters to be replaced.


The characters that will replace the characters in affectedCharRange; nil if only text attributes are being changed.

Return Value

YES to allow the replacement, or NO to reject the change.


If a delegate implements this method and not its multiple-selection replacement, textView:shouldChangeTextInRanges:replacementStrings:, it is called with an appropriate range and string. If a delegate implements the new method, then this one is ignored.

See Also

Setting Text Attributes

- textView:shouldChangeTextInRanges:replacementStrings:

Sent when a text view needs to determine if text in an array of specified ranges should be changed.

- textView:shouldChangeTypingAttributes:toAttributes:

Sent when the typing attributes are changed.

- textViewDidChangeTypingAttributes:

Sent when a text view’s typing attributes change.