Instance Method

textStorage(_:edited:range:changeInLength:invalidatedRange:)

Invalidates glyph and layout information for a portion of the text in the given text storage object.

Declaration

func textStorage(_ str: NSTextStorage, edited editedMask: Int, range newCharRange: NSRange, changeInLength delta: Int, invalidatedRange invalidatedCharRange: NSRange)

Parameters

aTextStorage

The text storage whose information is invalidated.

mask

Specifies the nature of the changes. Its value is made by combining with the C bitwise OR operator the constants described in “Change notifications” in NSTextStorage (editedAttributes and editedCharacters).

newCharRange

Indicates the extent of characters resulting from the edits.

delta

If the NSTextStorageEditedCharacters bit of mask is set, gives the number of characters added to or removed from the original range (otherwise its value is irrelevant).

invalidatedCharRange

Represents the range of characters affected after attributes have been fixed. Is either equal to newCharRange or larger. For example, deleting a paragraph separator character invalidates the layout information for all characters in the paragraphs that precede and follow the separator.

Discussion

This message is sent from the NSTextStorageobject’s processEditing() method to indicate that its characters or attributes have changed. This method invalidates glyphs and layout for the affected characters.

For example, after replacing “The” with “Several” to produce the string “Several files couldn’t be saved”, newCharRange is {0, 7} and delta is 4. The receiver uses this information to update its character-to-glyph mapping and to update the selection range based on the change.

The textStorage(_:edited:range:changeInLength:invalidatedRange:) messages are sent in a series to each NSLayoutManager object associated with the text storage object, so the layout managers receiving them shouldn’t edit aTextStorage while this method is executing. If one of them does, the newCharRange, delta, and invalidatedCharRange arguments are incorrect for all following layout managers that receive the message.

See Also

Deprecated

Deprecated Symbols

Review unsupported symbols and their replacements.