An NSArray is like this :
NSArray *array = @[@"One", @"Two", @"Three"];
//Loop through all NSArray elements
for (NSString *theString in array) {
NSLog(@"%@", theString);
}
//Get element at index 2
NSString *element = [array objectAtIndex:2];
//Or :
NSString *element = array[2];
If you have an object and you what to find its index in the array (object must be unique in array, otherwise will only return the first found) :
NSUInteger indexOfObject = [array indexOfObject:@"Three"];
NSLog(@"The index is = %lu", indexOfObject);
But if you are working with keys and values, maybe you need a NSDictionary.
An NSDictionary is like this :
NSDictionary *dictionary = @{@"myKey": @"Hello World !",
@"other key": @"What's up ?"
};
//Loop NSDictionary all NSArray elements
for (NSString *key in dictionary) {
NSString *value = [dictionary valueForKey:key];
NSLog(@"%@ : %@", key, value);
}