0

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

1 Answer 1

3
if ([compare containsObject:a]) {
   // show alert;
}

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.