gpt4 book ai didi

iphone - 将indexPath减一

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

我正在用 CoreData 填充 TableView。

到目前为止我一直在做这样的事情:

        NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath];

...检索对象以填充行。

一切都工作正常,直到我意识到我必须将表的第一行作为异常(exception)进行管理,因为第一行将包含 CoreData 未提供的其他内容。

现在我的问题是如何操纵indexPath 将所有内容移动一位。我想做这样的事情:

// I know this is not going to work, just to give you an idea...
NSManagedObject *managedObject = [self.fetchedResultsController objectAtIndexPath:indexPath-1];

但我找不到正确的语法来操作索引路径。谁能帮我?感谢您的宝贵时间!

最佳答案

如果我们谈论的是 iOS UITableView 索引路径,有更简单的方法:

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

干杯...:)

关于iphone - 将indexPath减一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8231386/

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