I'm working on an app that checks an array to see if it contains a certain string. However, it doesn't seem to be working right, because I think it may be looking at the case of the string. In this line of code, how would I make sure that containsObject: is being case insensitive?
if ([myArray containsObject:term]) {...}
Please ask if you need clarification, and thanks for your help.
(Also, I've found this question: Case insensitive comparison NSString. I don't know if this is what I need, and if it is, how would I use it)
if ([myArray indexOfObjectPassingTest:^(id obj, NSUInteger idx, BOOL *stop){
return (BOOL)([obj caseInsensitiveCompare:term] == NSOrderedSame);
}] != NSNotFound) {
// there's at least one object that matches term case-insensitively
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With