How to find whether an item is in NSArray or not ?
Hi,
Sometimes you may need to find/search a particular item in NSArray. How can you find whether a particular item is present in NSArray or not? Look at the code below.
BOOL testFlag= [yourArray containsObject:@"CoderzHeaven"];
if(testFlag) {
NSLog(@“Yup! It's present!"); }
else {
NSLog(@"Nopes! It's absent!"); }
Here ‘yourArray is your NSArray and ‘containsObject’ returns either TRUE or FALSE and it get stored in ‘testFlag’.
Link to this post!