Search code examples
objective-cmacosnstextviewnstextstorage

How can I make a NSTextView use a specific NSTextStorage?


Is there a way set an NSTextView's textStorage property to my own NSTextStorage? You can customize the NSTextContainer, so is there a way to do something like this:

NSTextView *myTV = [[NSTextView alloc] initWithFrame:CGFrameMake(0,0,100,100) 
                                    withTextStorage:myTextStorage];

If not, is there a way to swap out the default text storage after the text view is instantiated? Does this need to be done by subclassing NSTextView?


Solution

  • Other than simply replacing the string in the storage, it doesn't seem like there's a way to replace the NSTextStorage object itself.