Reputation: 4486
If I have an index path with value : { 0, 0}. What is the proper way to change it to { 0, 1} ? I know if it were an ordinary c array it would just be :
unsigned i_array[] = { 0, 0};
i_array[1] = 1;
But from NSIndexPath's documentation, the closest I can get is with :
– indexPathByRemovingLastIndex
– indexPathByAddingIndex:
It seems a bit cumbersome. Is there a way that I can just overwrite the last member of the index array ?
Upvotes: 3
Views: 3960
Reputation: 45210
NSIndexPath
is not an array. It's an object with 2 readonly properties: row
and section
. You can't change them, however, you can create a new indexPath based on the old one:
NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:oldIndexPath.row inSection:1];
oldIndexPath = newIndexPath;
Upvotes: 12