On 2 Mar '08, at 1:44 PM, Andrew Merenbach wrote:
You probably want to use enumerators and something like the
following code:
That's debatable. Personally, I hate using NSEnumerator because it's
slow. (Not only does it create an autoreleased enumerator object, but
most of the standard co
On Mar 2, 2008, at 12:31 PM, Tom Jones wrote:
I have an NSArray which contains String values and I want to loop
though it and determine if any of those string contain words I'm
looking for. I have tried but have been unsuccessful.
Predicates are great for this. They're a Foundation facilit
Or if your're on Leopard using the new enumerator:
NSString *searchFor = @"home";
NSRange range;
for (NSString *string in stringList)
{
range = [word rangeOfString:searchFor];
if (range.location != NSNotFound)
{
NSLog (@"Yay! '%@' found in '%@'.", searchFor, string);
}
}
Correc
Yep, I would've suggested fast enumeration, as I use them myself
regularly, except that a beginner might (or might not) find the
traditional paradigm easier.
Cheers,
Andrew
On Mar 2, 2008, at 2:01 PM, j o a r wrote:
On Mar 2, 2008, at 10:44 PM, Andrew Merenbach wrote:
You probabl
On Mar 2, 2008, at 10:44 PM, Andrew Merenbach wrote:
You probably want to use enumerators and something like the
following code:
...and if you're on 10.5 (or later - even if that's kind of unlikely
at this point) you'd use the new FAST enumerator:
for (NSString *string in array)
{
Hi, Tom,
You probably want to use enumerators and something like the following
code:
NSEnumerator *e = [array objectEnumerator];
NSString *string;
while ((string = [e nextObject])) {
NSRange range = [string rangeOfString:@"home"];
if (range.location != NSNotFound) {
On Mar 2, 2008, at 12:31 PM, Tom Jones wrote:
id obj;
obj = [array objectAtIndex:j];
/* Here is where I'm having trouble
I know this is not real :-)
if ( [obj inStr:@"home"])
http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NS
Hello,
I'm fairly new to Cocoa, so please excuse me if I'm not using the
right terminology.
I have an NSArray which contains String values and I want to loop
though it and determine if any of those string contain words I'm
looking for. I have tried but have been unsuccessful.
Example...