Check if NSMutableArray contains text from textfield
Posted
by
Polo Swelsen
on Stack Overflow
See other posts from Stack Overflow
or by Polo Swelsen
Published on 2012-06-13T10:33:20Z
Indexed on
2012/06/13
10:40 UTC
Read the original article
Hit count: 192
I want to check if the text inserted in a textfield is also in my NSMutableArray. So let's say my NSMutableArray has these objects: "Hey, Hello, No, Yes". Then when a user enters the text: "Hello" i want there to appear a UIAlertView. I now have the following:
for (int slt = 0; slt < [zouten count]; slt++) {
if (zout.text = [zouten objectAtIndex:slt]) {
alert = [[UIAlertView alloc]initWithTitle:@"Goedzo!" message:[NSString stringWithFormat:@"Je hebt een zout gevonden"] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
}
}
[alert show];
But somehow the message appears with every word. what am i doing wrong?
© Stack Overflow or respective owner