OGeek|极客世界-中国程序员成长平台

标题: ios - 创建后如何设置 NSIndexPath [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 23:43
标题: ios - 创建后如何设置 NSIndexPath

我使用以下方法创建了一个 NSIndexPath:

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];

现在我想通过修改此路径来通过 UITableView 建立索引,但我找不到任何在 NSIndexPath 中设置值的 API 调用

每次分配一个新的 NSIndexPath 似乎是一种巨大的浪费,特别是因为我实际上使用它来进行不分配任何内存的调用(协议(protocol)的补充)



Best Answer-推荐答案


I can't find any API calls that set values in an NSIndexPath.

因为没有 - NSIndexPath 是不可变的。

seems like a huge waste to allocate a new NSIndexPath every time

是的。对此感到抱歉。如果您关心这个,请将其包装到 @autoreleasepool { } 中。

关于ios - 创建后如何设置 NSIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13387085/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4