In order to break another problem down into smaller parts, I am trying to set up all the TextKit components. However, I am getting an crash after changing how I initialize <
It seems the way to do things, is to add the NSLayoutManager to the NSTextStorage object, (using addLayoutManager:) rather than setting the textStorage property on the layout manager.
From Apple's documents:
This method is invoked automatically when you add an NSLayoutManager to an NSTextStorage object; you should never need to invoke it directly, but you might want to override it. If you want to replace the NSTextStorage object for an established group of text-system objects containing the receiver, use replaceTextStorage:.
Link to setTextStorage: for NSLayoutManager
Presumably something gets done in 'addLayoutManager:' which doesn't get done in setTextStorage, causing the crash.
You might also want to increase the scope of the textStorage variable, if it appears that it's getting cleared up once viewDidLoad finish.