gpt4 book ai didi

iphone - 更改 NSIndexPath 对象的值

转载 作者:行者123 更新时间:2023-12-03 16:16:07 24 4
gpt4 key购买 nike

如果我有一个值为:{ 0, 0} 的索引路径。将其更改为 { 0, 1} 的正确方法是什么?我知道如果它是一个普通的 c 数组,它就会是:

unsigned i_array[] = { 0, 0};
i_array[1] = 1;

但是从 NSIndexPath 的文档中,我能得到的最接近的是:

– indexPathByRemovingLastIndex
– indexPathByAddingIndex:

好像有点麻烦。有没有办法可以覆盖索引数组的最后一个成员?

最佳答案

NSIndexPath 不是数组。它是一个具有 2 个只读属性的对象:rowsection。您无法更改它们,但是,您可以基于旧索引路径创建一个索引路径:

NSIndexPath *newIndexPath = [NSIndexPath indexPathForRow:oldIndexPath.row inSection:1];
oldIndexPath = newIndexPath;

关于iphone - 更改 NSIndexPath 对象的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9139699/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com