Ken & Jerry;

Thanks for the quick response!

So I've been pondering and testing...

1) Why would I have to bust up/loop on thePhrase? This makes me face Jerry's issue of a universal solution for breaking on words.
Just on general principal what would that solution be?
[thePhrase componentsSeparatedByString:@" "] sure is easy, fast and effective for most of the folks who are going to pay for indie software....
But what is the right solution??
Seems like a common enough problem that there should be a well- defined, easily obtained, well-documented answer....

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!!

thePhrase = 8 words
theTags = 150 words

the code below: 0.001 sec on 2Ghz MacBook   -- Yeeoowssah!

-- added benefits beyond spec
        -easy code to understand - not prone to error
-Search and Comparison options allow for easily implemented flexibility - case-sensitivity; anchored, etc..

- (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;
}

Thanks for making life good!
Steve
_______________________________________________

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

Reply via email to