Overview of Attribute Fixing in NSTextStorage
NSTextStorage
provides attribute fixing of user-entered text, via NSMutableAttributedString.fixAttributes(in:)
. Attribute fixing… NSMutableAttributedString.fixAttributes(in:)
always work on full paragraph ranges. It extends the passed-in range as needed “to cover the last paragraph partially contained”.
More Swifty NSAttributedString Attribute Query Methods
NSAttributedString
API takes an NSRange
by-reference. That’s cumbersome to use, though, because you need to initialize a non-nil range, and there you should initialize it with NSNotFound
to indicate an illegal state. Afterwards, you need to check if the range changed to a legal value.