• 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: Make a version of NSData "rangeOfData: options: range:" for multiple search parameters
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Make a version of NSData "rangeOfData: options: range:" for multiple search parameters


  • Subject: Re: Make a version of NSData "rangeOfData: options: range:" for multiple search parameters
  • From: Jens Alfke <email@hidden>
  • Date: Fri, 15 Apr 2016 10:14:58 -0700

> On Apr 14, 2016, at 9:33 PM, Daryle Walker <email@hidden> wrote:
>
> I need a version of the method listed in the subject that works on multiple search strings instead of one, stopping at the first & longest match.  Any ideas?

Depends on your requirements…

If performance isn’t critical, just call -rangeOfData: on each search string, then pick the match with the minimum location. (If you don’t know whether performance will be critical, do it this way anyway and then profile the app to see if it’s fast enough.)

If that’s not fast enough, and the data is text, NSRegularExpression might be faster. You’ll need to construct a regex of the form “foo|bar|baz”, i.e. the search strings separated with “|”. Metachars in the search strings need to be escaped. The actual search should be fast, but constructing the regex will have some overhead.

If neither of those is good enough, then you may have to crack open some books (or search Github) to find a multiple string search algorithm.

—Jens
_______________________________________________

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


References: 
 >Make a version of NSData "rangeOfData: options: range:" for multiple search parameters (From: Daryle Walker <email@hidden>)

  • Prev by Date: Signed App can't retrieve passwords from keychain
  • Next by Date: Re: Signed App can't retrieve passwords from keychain
  • Previous by thread: Make a version of NSData "rangeOfData: options: range:" for multiple search parameters
  • Next by thread: CFBridgingRetain does not leak memory
  • Index(es):
    • Date
    • Thread