why my NSIndexPath
value is not [0,1]
but [0,64]
, how could I get [0,1]
?
Asked
Active
Viewed 146 times
1 Answers
1
An NSIndexPath
does not simply store Int
s like it is an Array
, so direct inspection like you are doing does not reflect what you would get if you ran print(indexPath.row)
.

sschale
- 5,168
- 3
- 29
- 36
-
I'm not so sure your index paths are actually row 64 - but to verify you can add the code `print("Row: \(indexPath.row), Section: \(indexPath.section)")` to your loop to see what values you have. – sschale Feb 27 '16 at 05:41
-
Row: 0, Section: 0 Row: 1, Section: 0 Row: 2, Section: 0 ... ... 2016-02-27 13:51:54.968 qiushibaike[74747:3906422] *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3505.16/UITableView.m:1424 – side3 Feb 27 '16 at 05:55
-
It looks like there's an error in how you're going about updating the number of rows in your tableView - if you update your data model and just call `reloadData` you can avoid this issue entirely, but without seeing the rest of your code we can't point to the exact error. However, I might posit that the way you are calculating the rows to enumerate over is faulty, as it is using absolute number of rows changed versus the actual rows that were changed. – sschale Feb 27 '16 at 06:04
-
thanks very much ,I am new to iOS. in this method I just want to perform --when there were 10 cells in tableView already, and I press the update button, I append 10 more model data to the dataArray,But I don't wanna call `reloadData` to update all the model data, I just wanna update the new 10 cells just get. how do I make that? – side3 Feb 27 '16 at 07:15
-
Ok, so if you're adding cells, you want to use `tableView.insertRowsAtIndexPaths:`, called in between `tableView.beginUpdates()` and `tableView.endUpdates()'. Would you mind accepting my answer? – sschale Feb 27 '16 at 07:45
-
ok,this resolves the problem,thank you @sschale. And may I ask why the indexPath in the picture upon ,its value is {0,64} ? – side3 Feb 27 '16 at 08:10
-
I'm not sure, but again, don't worry about the literal printout from there, instead inspect an indexPath using .row and .section. – sschale Feb 27 '16 at 08:12