0

I have a NSString which contains multiple (thousand) names (forenames and surnames), and I would like the opportunity to input a name (forename or surname or both) in to a UITextView, and then check if the name is on the list.

Let's find a surname!

for (NamesString *items in _feedArray){
    if ([nameText.text isEqualToString: items.surname]){
       NSLog(@"BINGO");
    }else{
       NSLog(@"NOPE");
     }
}

I always get NSLog(@"NOPE").

  • What ur feedArray contains and what is ur input? – Arjuna Jun 18 '14 at 18:12
  • 3
    You should really check the documentation. NSArray has a `containsObject:` method. – Mick MacCallum Jun 18 '14 at 18:12
  • Are you sure there isn't a single `NSLog(@"BINGO")` hidden among thousands of `NSLog(@"NOPE")`? Also, could you post an example of `nameText.text` and `items.surname`? It could be that you have a stray space or comma that's causing `isEqualToString:` to return `false`. – Kamaros Jun 18 '14 at 18:13
  • The array contains forenames and surnames. – user3753385 Jun 18 '14 at 19:03

0 Answers0