Why is the length of NSIndexPath always showing 2?

I created an NSIndexPath object, but when I print the value of its length property, it will always show the value as 2.

NSIndexPath *index = [NSIndexPath indexPathForItem:0 inSection:4]; 

{length = 2, path = 4 - 0}

Why is the length always 2?

+8
ios nsindexpath
source share
2 answers

Since the index path consists of two indices - the section and the element number.

+13
source share

basically NSIndexPath is a combination of Section and Row, so it will show the length as 2.

+2
source share

All Articles