@Owen Godfrey's answer is better than the accepted answer from @iPatel. Here is another clarification that I could not insert in the commentary on his answer, so I will copy his answer and add it here. The loan belongs to Owen.
From @Owen Godfrey:
Inside NSIndexPath, indexes are stored in a simple c array called "_indexes", defined as NSUInteger *, and the length of the array is stored in "_length", defined as NSUInteger. The Accessor section is an alias of _indexes [0], and both item and row are aliases for _indexes 1 , so they are functionally identical.
In terms of programming style, and possibly the definition chain, you'd better use a “row” in the context of tables and an “element” in the context of collections.
The main interface of NSIndexPath is defined in NSIndexPath.h. Index storage is in _indexes, which is a private one-dimensional array of NSUInteger. NSIndexPath itself can represent any number of dimensions. There are two corresponding categories on NSIndexPath that extend the functionality: one of the UICollectionView.h "NSIndexPath (UICollectionViewAdditions)" and one of the UITableView.h "NSIndexPath (UITableView)". One of UICollectionView.h adds the "item" readonly property and associated convenience methods. One of UITableView.h adds the readonly string property and its convenience methods. However, both properties are simply shells that access the base value in _indexes [1].
Because UIKit associates with both categories, both sets of handy features are always available, regardless of where you use them on iOS. Therefore, you can create NSIndexPath from [NSIndexPath indexPathForRow: inSection:], but get the second index from indexPath.item. The base value is exactly the same, regardless of whether it turned to indexPath.item or indexPath.row.
Stylistically, it’s cleaner if you use an “element” with a UICollectionView and a “row” with a UITableView, as they are intended to be used, and this makes the code more readable. However, your program will not crash if you replace them.
Link: NSIndexPath
spencery2 Dec 22 '15 at 10:26 2015-12-22 10:26
source share