Instance Method

edited(_:range:changeInLength:)

Tracks changes made to the receiver, allowing the text storage to record the full extent of changes made.

Declaration

func edited(_ editedMask: NSTextStorageEditActions, range editedRange: NSRange, changeInLength delta: Int)

Parameters

mask

A mask specifying the nature of the changes. The value is made by combining with the C bitwise OR operator the options described in NSTextStorageEditActions.

oldRange

The extent of characters affected before the change took place.

lengthChange

The number of characters added to or removed from oldRange. If no characters where edited as noted by mask, its value is irrelevant and undefined. For example, when replacing “The” with “Several” in the string “The files couldn’t be saved”, oldRange is {0, 3} and lengthChange is 4.

Discussion

This method invokes processEditing() if there are no outstanding beginEditing() calls. NSTextStorage invokes this method automatically each time it makes a change to its attributed string. Subclasses that override or add methods that alter their attributed strings directly should invoke this method after making those changes; otherwise you should not invoke this method. The information accumulated with this method is then used in an invocation of processEditing() to report the affected portion of the receiver.

The methods for querying changes, editedRange and changeInLength, indicate the extent of characters affected after the change. This method expects the characters before the change because that information is readily available as the argument to whatever method performs the change (such as replaceCharacters(in:with:)).

See Also

Handling Text Editing Messages

func ensureAttributesAreFixed(in: NSRange)

Ensures that attributes are fixed in the given range.

var fixesAttributesLazily: Bool

A Boolean value indicating whether the text storage object fixes attributes lazily.

func invalidateAttributes(in: NSRange)

Invalidates attributes in the specified range.

func processEditing()

Cleans up changes made to the receiver and notifies its delegate and layout managers of changes.