views:

166

answers:

1

Good Day!

I want to search a specific string in the array of strings in objective c. Can somebody help me in this regard?

Thanks

A: 
BOOL isTheObjectThere = [myArray containsObject: @"my string"];

or if you need to know where it is

NSUInteger indexOfTheObject = [myArray indexOfObject: @"my string"];

I strongly recommend you read the documentation on NSArray. In fact, you probably should have done that before posting your question :-)

JeremyP
lets say i have an array containingNSArray *myArr = [[NSArray alloc] initWithObjects:@"test1", @"test3",@"test3", nil];i wanted to search "tes" lets say then i wanted a wild card stuf to work, that i could not understand, so i put this question, but thanks for the reply, appreciated
Ch Sab
You either loop through and test each value, or look into NSPredicate which provides pretty comprehensive searching for collection objects - almost as powerful as SQL where clauses.http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/Predicates/predicates.html#//apple_ref/doc/uid/TP40001789
JeremyP