开发者

Is It Possible To Adjust indexPath?

开发者 https://www.devze.com 2023-04-04 09:46 出处:网络
Under a table view delegate, indexPath is sent. Is it possible to assign this to a local variable and then adjust it? I didn\'t see anything in the class reference docs.

Under a table view delegate, indexPath is sent. Is it possible to assign this to a local variable and then adjust it? I didn't see anything in the class reference docs.

What I'm trying to do is add 1 to the indexPath.row.

This code doesn't work, but I'm putting it here to get the basic idea across.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSIndexPath *tempIndex;
    tempIndex = indexPath;
    tempIndex.row = tempI开发者_StackOverflowndex.row + 1;
//etc...
}

Thanks in advance


You can get another NSIndexPath by calling

NSIndexPath *tempIndex = [NSIndexPath indexPathForRow:indexPath.row + 1 inSection:indexPath.section];

Although I don't understand what you mean by "adjusting" it. Typically, in cellForRowAtIndexPath, you don't work with other paths/cells that the one which is asked for.

0

精彩评论

暂无评论...
验证码 换一张
取 消