views:

27

answers:

1

hi all, another quick question. how to compare an string with the values of an array for example

string a =@"abc";

compare = [[NSMutableArray arrayWithObjects:@"a",@"b",@"abc",@"d",nil]];

if string matches any of the element in array, i should show some alert or something.

regards

+2  A: 
if ([compare containsObject:a]) {
   // show alert;
}

If that array will become arbitrarily long, it's better to use an NSSet instead.

KennyTM
awesome...got it working.thanks a lot Kenny
shishir.bobby