Strategies for dynamic modification of search results in NSTextViews

  • Dear list,

    I have an app which managed a bunch of files and presents these text files for viewing and editing in NSTextViews. I have implemented a project-wide search functionality which works fine, but with one problem. If the user changes the text in one file after making a search, then the search results are no longer valid. A typical use-case is to make a search for a word or phrase, then go through each result and modify it. Problem is, after the first modification by the user, the subsequent results are no longer accurate/valid.

    Does anyone have any good suggestions as to how to update my search results when the underlying source text changes? Do I have to listen for all changes from the underlying text objects and try to adapt, or is there a better pattern for doing this? Xcode does this nicely: no matter what changes you make in the editor, the search results are updated on the fly.

    Cheers,

    Martin
previous month january 2012 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today