• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Dynamic modification of text search results
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic modification of text search results


  • Subject: Re: Dynamic modification of text search results
  • From: Marco Tabini <email@hidden>
  • Date: Wed, 04 Jul 2012 09:22:16 -0400

> 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 seem to be updated on the fly.

Couple of random suggestions:

* If you're using NSAttributedString, you can mark your search results by assigning custom attributes to specific ranges of text; as the text changes, those attributes will stick around and you can later find them using the attribute retrieval methods (I believe that's what Xcode does).

* As an alternative, a more naïve approach could be to simply repeat the search every time you detect the text changing, but depending on the size of your text files, that could eat up a lot of CPU cycles, and is just inelegant.

I'm sure there are other possibilities, too, but these two are the first ones that come to mind.

HTH,


—Mt.
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Dynamic modification of text search results
      • From: Martin Hewitson <email@hidden>
    • Re: Dynamic modification of text search results
      • From: Martin Hewitson <email@hidden>
References: 
 >Dynamic modification of text search results (From: Martin Hewitson <email@hidden>)

  • Prev by Date: Dynamic modification of text search results
  • Next by Date: Crash in System Prefs when installing PrefPane
  • Previous by thread: Dynamic modification of text search results
  • Next by thread: Re: Dynamic modification of text search results
  • Index(es):
    • Date
    • Thread