The fact of the matter is that your array is 10 items long. The comments above aren't saying "you should remove "Acceleration X" to make it 10 items long", they're saying "you're mistaken in your belief that your array is 11 items long".
Without seeing more code, it's difficult to say what's really going on here; but anyway, you shouldn't be using -allValues
, because the ordering in that array is undefined, which makes it unsuitable for use backing a table view.
Instead, you should keep an array of the keys of the dictionary in whatever order you want them to display, and then reference _items[key]
directly.
For example:
_keys =
@[
@"Red",
@"Orange",
@"Yellow",
@"Green",
@"Blue",
@"Indigo",
@"Violet"
];
_dictionary =
@{
@"Blue": @"Battle",
@"Green": @"Gave",
@"Indigo": @"In",
@"Orange": @"Of",
@"Red": @"Richard",
@"Violet": @"Vain"
@"Yellow": @"York",
};
- (NSString *)labelTextForIndexPath:(NSIndexPath *)indexPath
{
return _keys[indexPath.row];
}
- (NSString *)detailLabelTextForIndexPath:(NSIndexPath *)indexPath
{
return _dictionary[_keys[indexPath.row]];
}