iOS Guides | Samples

MonoTouch.UIKit.NSTextStorage Class

A subclass of NSMutableAttributedString that supports Core Text layout management.

See Also: NSTextStorage


[MonoTouch.Foundation.Register("NSTextStorage", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 7, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
public class NSTextStorage : NSMutableAttributedString


iOS 7 introduced "Text Kit," a broad set of APIs and modifications of existing classes, built on MonoTouch.CoreText, that greatly expands the typographical flexibility of iOS.

An NSTextStorage object holds the text that is to be displayed. As with NSMutableAttributedString, application developers can manipulate text styles using NSMutableAttributedString.AddAttribute or NSMutableAttributedString.AddAttributes. The key addition to NSTextStorage is that it maintains references to one or more NSLayoutManagers (NSTextStorage.LayoutManagers) , which are responsible for converting text characters into glyphs and laying them out in accordance with the NSLayoutManagers' associated UITextView and NSTextContainer objects.

If you subclass NSTextStorage, you must override four methods. Two from NSAttributedString (NSAttributedString.LowLevelValue and NSAttributedString.LowLevelGetAttributes) and two from NSMutableAttributedString (AttributedString.LowLevelSetAttributes and NSMutableAttributedString.Replace(NSRange,String)).

The reason why you must override the low-level methods is because NSTextStorage is a very chatty interface that likes to call those methods up to thousands of times for each character that the user enters. So it important to use the low-level interface. You can review some of Xamarin's samples to see how to implement those if you have questions on how to do this.

Since NSTextStorage is a very chatty API,

Related content


Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions:

The members of MonoTouch.UIKit.NSTextStorage are listed below.

See Also: NSMutableAttributedString

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

ChangeInLengthInt32. The change in length for the pending changes.
ClassHandleIntPtr. The handle for this class.
DelegateNSTextStorageDelegate. An instance of the MonoTouch.UIKit.NSTextStorageDelegate model class which acts as the class delegate.
EditedMaskNSTextStorageEditActions. The kinds of edits pending for this NSTextStorage.
EditedRangeNSRange. The range in this NSTextStorage in which pending changes have been made.
FixesAttributesLazilyBoolean. Whether this NSTextStorage fixes attributes lazily. Read-only.
LayoutManagersNSObject[]. The NSLayoutManagers associated with this NSTextStorage. Read-only.
WeakDelegateNSObject. An object that can respond to the delegate protocol for this type

Public Methods

Adds an NSLayoutManager to this NSTextStorage.
Edited(NSTextStorageEditActions, NSRange, Int32)
Indicates a change.
Ensures that attributes have been fixed in the given range.
Invalidates attributes in the specified range.
Activates post-editing operations.
Removes an NSLayoutManager from this NSTextStorage's LayoutManagers collection.

Protected Methods

Releases the resources used by the NSTextStorage object.

Public Events

DidProcessEditingEvent raised by the object.
WillProcessEditingEvent raised by the object.