NSIndexpath.item与NSIndexpath.row [英] NSIndexpath.item vs NSIndexpath.row

查看:134
本文介绍了NSIndexpath.item与NSIndexpath.row的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道 NSIndexpath.row NSIndexpath.item 之间的区别?

Does anyone know the difference between NSIndexpath.row and NSIndexpath.item?

具体来说,我使用哪一个:

Specifically, which one do I use in:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;


推荐答案

好的,没有人在这里给出了一个好的答案。

Okay, nobody has given a good answer here.

内部NSIndexPath,索引被存储在被称为_indexes定义为NSUInteger *和数组的长度被存储在定义为NSUInteger_length一个简单的C数组。访问者section是_indexes [0]的别名,item和row都是_indexes [1]的别名。因此两者在功能上是相同的。

Inside NSIndexPath, the indexes are stored in a simple c array called "_indexes" defined as NSUInteger* and the length of the array is stored in "_length" defined as NSUInteger. The accessor "section" is an alias to "_indexes[0]" and both "item" and "row" are aliases to "_indexes[1]". Thus the two are functionally identical.

在编程风格方面 - 也许是定义链 - 你最好在表的上下文中使用row,并且项目在集合的上下文中。

In terms of programming style – and perhaps the definition chain – you would be better using "row" in the context of tables, and "item" in the context of collections.

这篇关于NSIndexpath.item与NSIndexpath.row的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆