• 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: Approaches for this Matching Problem?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Approaches for this Matching Problem?


  • Subject: Re: Approaches for this Matching Problem?
  • From: Ken Thomases <email@hidden>
  • Date: Mon, 22 Jun 2009 12:52:24 -0500

On Jun 22, 2009, at 3:10 AM, Steve Cronin wrote:

So I've been pondering and testing...

1) Why would I have to bust up/loop on thePhrase?

BUT in my case I don't care where, what word or how often - I just want to know IF a tag occurs in thePhrase!!

Then you shouldn't refer to "words". If you just care if any of a set of strings appear in a given string, that's a different question.


If one of your tags is "ham", do you want it to match a phrase containing "shame"?


- (BOOL) containsTag:(NSString *)thePhrase {
BOOL tagFound = NO;
NSString *tag;
NSEnumerator *tagEnum = [tags objectEnumerator]; //tags is an NSSet instance variable built from Core Data
while ((tag=[tagEnum nextObject])!=nil) {
if ([thePhrase rangeOfString:tag options:NSCaseInsensitiveSearch].location!=NSNotFound) {
tagFound = YES; break;
}
}
return tagFound;
}

If you can target Leopard or later, you can simplify this even more by using "for (NSString* tag in tags) ...". It's more efficient, too.


Regards,
Ken

_______________________________________________

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: Approaches for this Matching Problem?
      • From: Steve Cronin <email@hidden>
References: 
 >Approaches for this Matching Problem? (From: Steve Cronin <email@hidden>)
 >Re: Approaches for this Matching Problem? (From: Steve Cronin <email@hidden>)

  • Prev by Date: re: renaming executable files
  • Next by Date: How do I sync Quartz drawing-path coordinates with the physical iPhone UIView coordinates?
  • Previous by thread: Re: Approaches for this Matching Problem?
  • Next by thread: Re: Approaches for this Matching Problem?
  • Index(es):
    • Date
    • Thread