I have an array and I want to check if one string is in the array, without looping. Just using "if's" I know if some string exists or not in the array.
Is there any possibility?
Use -[NSArray containsObject:].
(You don't have to write the loop yourself, but of course NSArray almost certainly has to use a loop internally.)
if ([array containsObject:string])
NSLog(@"Yes, the array contains my string.")
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