I have an array of NSString.
exampleArray = @[@"5", @"6", @"7", @"8", @"9", @"10", @"11", @"12", @"13", @"14", @"15", @"16", @"17", @"18", @"19", @"20"];
Let's say you have..
NSString *exampleString = @"7";
I want to find exampleString, in exampleArray, and have it return the index of 2, the index where @"7" is located.
What is the best way to do this besides looping through and comparing isEqualToString?
if([exampleArray containsObject:exampleString]) {
int index = [exampleArray indexOfObject: exampleString];
} else {
NSLog(@"not found");
}
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