NSIndexPath getIndexes 方法...如何?
我对该方法的使用以及将其列为(无效)方法的文档感到困惑。
“返回索引路径的索引”
它在哪里也返回任何内容?
不应该是:
- (NSIndexPath *)getIndexes:(NSUInteger *)indexes
getIndexes: 提供对索引路径索引的引用。
- (void)getIndexes:(NSUInteger *)indexes
参数 索引 指向无符号整数数组的指针。返回时,索引路径的索引。 可用性 适用于 iOS 2.0 及更高版本。 申报于 NSIndexPath.h
Am confused with the use of this method and the documentation that lists it as a (void) method.
"on return the index path's indexes"
where does it return anything too?
Should it not be:
- (NSIndexPath *)getIndexes:(NSUInteger *)indexes
getIndexes:
Provides a reference to the index path’s indexes.
- (void)getIndexes:(NSUInteger *)indexes
Parameters
indexes
Pointer to an unsigned integer array. On return, the index path’s indexes.
Availability
Available in iOS 2.0 and later.
Declared In
NSIndexPath.h
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您必须分配大小为 [indexPath length] 的 NSUInteger 数组并将其作为参数传递。返回值将写在那里。您必须自己释放该数组,或者不执行在堆栈上创建的数组,如下所示:
You have to allocate the NSUInteger array of size [indexPath length] and pass it as argument. The return value will be written there. You have to release that array yourself or do nothing it was created on stack like this:
也许下一句话就能解释原因
它实际上是一个指向 C 数组的指针,该数组将为您填充索引,因此没有理由另外从函数中返回它 - 您已经知道它的地址。
您可以按如下方式使用该功能
Maybe the next sentence explains the reason
It's actually a pointer to a C array that will be filled for you with the indexes, so there's no reason to additionally return it from the function - you already know its address.
You can use the function as follows
您将该消息发送到 NSIndexPath 的一个实例,因此返回该消息并没有帮助。 -getIndexes: 方法用索引路径中的索引填充数组“indexes”。因此,您可以执行以下操作:
之后,索引将填充indexPath 中的索引值。
You send that message to an instance of NSIndexPath, so getting one back wouldn't help. The -getIndexes: method fills the array 'indexes' with the indexes from the index path. So you'd do something like:
After that, indexes will be filled with the index values that are in indexPath.
马克斯、托马斯和迦勒,我已经尝试了所有三种方法,但无法让任何东西发挥作用,所以也许太快地推出了接受的解决方案......但可能更有可能我只是不明白?我无法获得正确的数组大小,以便循环遍历它以访问表中所需的行。我认为对于 5 行的组,
calloc([indexPath length], sizeof(NSUInteger))
会返回一个包含 5 行的数组,每行保存NSUIntegr
。 ....或者我离得太远很尴尬吗?Max, Thomas and Caleb, I have tried all three ways and cannot get anything to work, so maybe fired off the accepted solution too quick.....but probably more likely I just don't get it? I can't get the right size of the array in order to loop through it to access the required rows in my table. I would have though that
calloc([indexPath length], sizeof(NSUInteger))
would for a group with 5 rows return an array with 5 rows with each row holdingNSUIntegr
.....or am of so far off beam it embarrassing?