TextKit Overview
TextKit goes back to the NeXT era, before Mac OS X was a thing. After the relatively new Cocoa frameworks for Mac app programming were introduced and introduced the “Cocoa Text System” title, iOS and UIKit stuck with “TextKit”, and in 2021 TextKit 2 returned.
This revolves around everything related to accepting textual user input on the Mac:
-
NSTextView
for the UI component, -
NSTextStorage
for the processing of text and style changes, -
NSLayoutManager
for the computation of line and glyph sizes, and for applying styles, -
NSTypesetter
for putting glyphs on the screen.
Even NSTextField
s are just reusing a shared NSTextView
, called the window’s field editor. It’s everywhere.
- TextKit API docs: describes all core components and, since TextKit 2, comes with sample projects and WWDC links.
- TextKit 2 Introduction (WWDC 2021)