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 (Cocoa-dev@lists.apple.com)
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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com
This email sent to arch...@mail-archive.com