How to extract text string from a CTlineRef ?
i know for example that i can do CTLineGetStringRange(aLine) and i have the AttributedString (ie: CFAttributedStringRef) that was used to generate the line. how to extract the text string from the AttributedString ?
So you have this:
Convert the
CFRange
to anNSRange
and cast theCFAttributedStringRef
to anNSAttributedString *
:Then you can use an Objective-C message to get the substring. If you want an attributed substring:
If you want a plain substring:
If you want to stick with Core Foundation functions for some reason (I wouldn't recommend it), you can get the attributed substring:
Or the plain substring like this: