Hi,
I have a NSMutableArray with a few NSString objects in , how can i test if it contains a particular string literal
i tried [array containsObject:@"teststring"] but it doesn't work.
Thanks
Hi,
I have a NSMutableArray with a few NSString objects in , how can i test if it contains a particular string literal
i tried [array containsObject:@"teststring"] but it doesn't work.
Thanks
for every object
[(NSString *) [array objectAtIndex:i] isEqualToString:@"teststring"];
What you're doing should work fine. For example
NSArray *a = [NSArray arrayWithObjects:@"Foo", @"Bar", @"Baz", nil];
NSLog(@"At index %i", [a indexOfObject:@"Bar"]);
Correctly logs "At index 1" for me. Two possible foibles:
indexOfObject
sends isEqual
messages to do the comparison - you've not replaced this method in a category?NSNotFound
for failure to locate, and not (say) 0.