0

We have an NSTextView that could possibly contains large amounts of text. I'm using it to replace an NSTableView, which was far too slow when it was generating thousands of rows. We also have an NSSearchField, which used to apply its predicate to the table's array controller to narrow it down to only rows containing a given string. Now I want to do the same with the text view.

I tried applying a custom attribute to the found ranges in the NSTextStorage, then used the NSLayoutManagerDelegate method -layoutManager:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange: to set the glyph properties of the non-marked ranges to NSGlyphPropertyNull. This resulted in many errors:

_NSGlyphTreeGlyphRangeForCharacterRange missing glyphs 1

And it brought the app to its knees. Is there some better way to filter the display of the textStorage and only draw the paragraphs we found?

For now, it has to work on 10.10. Bleh.

  • Thousands of rows in a table view shouldn't be a problem. – Willeke Feb 17 '18 at 13:20
  • It is. Filling a text view with the text takes a fraction of a second, where reading that same file and breaking it into thousands of substrings and adding them to an array controller takes ~10 seconds. I asked a question about NSLayoutManager, not surmises about tables. – Steve Mills Feb 19 '18 at 04:11
  • The conversion of the data is too slow, not the table view. – Willeke Feb 19 '18 at 13:17
  • No it is not. Quit assuming you can see how my code is behaving. I said "AND adding them to an array controller". Do you have anything constructive to offer about my actual NSLayoutManager question? – Steve Mills Feb 19 '18 at 16:00
  • I don't want future readers to think that `NSTableView` can't display thousands of rows. – Willeke Feb 19 '18 at 16:34

0 Answers0