Creating the custom text view

We're very close to being done, as we did the bulk of the work in creating our custom text storage. These are the steps we have still to complete:

  1. Create an NSTextView programmatically, using native implementations of the NSTextContainer and NSLayoutManager classes.
  2. Declare the ViewController instance to be its delegate.
  3. Add the text view as a subview of the View Controller.
  4. Create an instance of CustomTextStorage and add the text view's layout manager as an observer, to be notified when changes occur.

We'll put all of those steps into a createTextView method, which we will call from the viewDidLoad method of the ViewController.

Add the following method to the ViewController class (not the CustomTextStorage ...

Get Mastering macOS Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.