The sample code also changes the textStorage inside the block passed to textContentManager.performEditingTransaction(_:), which the documentation doesn't seem to explain why it's necessary.
If I remember correctly, we mentioned that in the Meet TextKit 2 WWDC session when doing the code demo, but it is unfortunate that we haven't documented that in the API reference. You might consider filing a feedback report (http://developer.apple.com/bug-reporting/) against that.
Making changes on textStorage
in the closure of performEditingTransaction(_:)
is important because it makes sure the changes are synchronized to the text layout managers and trigger a text view update, if necessary. Please be sure that you do that whenever you change the text storage.
is there any docs for TextKit2 and how its new classes interface with each other?
To understand how the classes interact with each other, the best thing to get started is probably the Meet TextKit 2 WWDC session, as mentioned above.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.