NSIndexpath.item vs NSIndexpath.row

Does anyone know the difference between NSIndexpath.row and NSIndexpath.item?

Specifically, which one do I use in:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;

Okay, nobody has given a good answer here.

Inside NSIndexPath, the 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 to "_indexes[0]" and both "item" and "row" are aliases to "_indexes[1]". Thus the two are functionally identical.

In terms of programming style – and perhaps the definition chain – you would be better using "row" in the context of tables, and "item" in the context of collections.


indexPath.row is best in your case 

First info about NSIndexPath

The NSIndexPath class represents the path to a specific node in a tree of nested array collections. This path is known as an index path.

Each index in an indexPath represents the index into an array of children from one node in the tree to another, deeper node.

For example, the indexPath 1.4.3.2 specifies the path shown in Figure enter image description here

Here in your case indexPath.row returns the index of the row at the specific indexPath.

Differences between indexPath.row and indexPath.item

Generally indexPath has two properties

1 - row

2 - item

row - property use with UITableView for get specific row base on indexPath. it is also read only property

 Available in iOS 2.0 and later.

item - properly use with UICollectionView for get item in section. It is a read-only property. To use this property you need to declare it in
UICollectionView.h

>     Available in iOS 6.0 and later.