iOS Developer Library

Developer

UIKit Framework Reference NSTextStorageDelegate Protocol Reference for iOS

Options
Deployment Target:

On This Page
Language:

NSTextStorageDelegate

The NSTextStorageDelegate protocol defines the optional methods implemented by delegates of NSTextStorage objects.

Inheritance


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 7.0 and later.
  • Sent when a text storage object is about to process edits.

    Declaration

    Swift

    optional func textStorage(_ textStorage: NSTextStorage, willProcessEditing editedMask: NSTextStorageEditActions, range editedRange: NSRange, changeInLength delta: Int)

    Objective-C

    - (void)textStorage:(NSTextStorage *)textStorage willProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)delta

    Parameters

    textStorage

    The text storage object processing edits.

    editedMask

    The types of edits to do: NSTextStorageEditedAttributes, NSTextStorageEditedCharacters, or both.

    editedRange

    The range in the original string (before the edit).

    delta

    The length delta for the editing changes.

    Discussion

    Sent inside processEditing right before fixing attributes. Delegates can change the characters or attributes.

    The delegate can verify the changed state of the text storage object and make changes to the text storage object’s characters or attributes to enforce whatever constraints it establishes. Programmatic changes don’t cause this message to be sent.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.

  • Sent when a text storage object has finished processing edits.

    Declaration

    Swift

    optional func textStorage(_ textStorage: NSTextStorage, didProcessEditing editedMask: NSTextStorageEditActions, range editedRange: NSRange, changeInLength delta: Int)

    Objective-C

    - (void)textStorage:(NSTextStorage *)textStorage didProcessEditing:(NSTextStorageEditActions)editedMask range:(NSRange)editedRange changeInLength:(NSInteger)delta

    Parameters

    textStorage

    The text storage object processing edits.

    editedMask

    The types of edits done: NSTextStorageEditedAttributes, NSTextStorageEditedCharacters, or both.

    editedRange

    The range in the original string (before the edit).

    delta

    The length delta for the editing changes.

    Discussion

    Sent inside processEditing right before notifying layout managers. Delegates can change the attributes.

    The delegate can verify the final state of the text storage object; it can’t change the text storage object’s characters without leaving it in an inconsistent state, but if necessary it can change attributes. Note that even in this case it’s possible to put a text storage object into an inconsistent state—for example, by changing the font of a range to one that doesn’t support the characters in that range (such as using a Latin font for Kanji text).

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later.