Object at index in NSArray Object at index in NSArray arrays arrays

Object at index in NSArray


if you just want to check if there is an object

if (myIndex < [array count])

if you want to find a specific object

[array indexOfObject:myObject];

if you want to know if the object at some index is of some class

[[array objectAtIndex:myIndex] isKindOfClass:[TheClassToCompareTo class]];


BOOL exists = index < [array count] ? YES : NO;


You can use containsObject method to check weather your array contains the specific object or not. If contains, then get its index by indexOfObject method

if ([yourArrayArray containsObject:yourObject]) {    NSLog(@"Found");    int index = [yourArray indexOfObject:yourObject];     }