NSIndexPath

是Foundation框架中的一个普通的类,它提供了到嵌套数列的树中特定节点的路径,事实上,它是一个整数阵列,表格视图使用这个去表现在特定章节中的特定行,UITableView用的所有索引路径正好有两个元素,第一个是章节,第二个是行。

NSIndexPath和TableViews

@interfaceNSIndexPath (UITableView) {

}

+(NSIndexPath*)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section;

@property(nonatomic,readonly)NSUIntegerrow;

@property(nonatomic,readonly)NSUIntegersection;

@end

 

NSIndexPath是一種特別的資料類別,這是用來表示一個路徑,這個路徑是指到一個從0開始的巢狀集合陣列樹狀結構的某個節點。iPhone OS為UITableView擴充了這個類別(見NSIndexPath UIKit Additions這是用分類擴充),加入了一個用來建立新的NSIndexPath實體的「(NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section」方法和row和section兩個屬性。

原帖:http://blog.163.com/[email protected]/blog/static/68486388201011255624582/

原博文:http://blog.csdn.net/bellajo/article/details/6772556

nsindexpath的compare方法:

compare:

Indicates the depth-first traversal order of the receiving index path and another index path.

- (NSComparisonResult)compare:(NSIndexPath *)indexPath

Parameters
indexPath

Index path to compare.

This value must not be nil. If the value is nil, the behavior is undefined.

Return Value

The depth-first traversal ordering of the receiving index path and indexPath.

Availability
  • Available in Mac OS X v10.4 and later.
Declared In

NSIndexPath.h

来源:http://blog.sina.com.cn/s/blog_642e41c20100x5hn.html

时间: 2024-08-19 08:23:09

NSIndexPath的相关文章

NSIndexPath 延伸

转载自:http://my.oschina.net/u/2560887/blog/602095?fromerr=Dy4vj5Jd 这个类的实例描述了一个嵌套数组中特定节点的路径,一般叫做索引路径.1.4.3.2 索引路径中的每一个索引值描述了在那一层数组中的位置. A10               A21 ----           02     |          13     |          24     |          35     |-------->4 第一次接触这个

IOS UITableView NSIndexPath属性讲解

IOS UITableView NSIndexPath属性讲解 查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和delegate. dataSource 是UITableViewDataSource类型,主要为UITableView提 供显示用的数据(UITableViewCell),指定UITableViewCell支持的编辑操作类型(insert,delete和 reordering),并根据用户的操作进行相应的数据更

- (void)deleteRowsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;删除报错问题

前几天做UItableView删除cell的时候报了这个错: *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-3347.44.2/UITableView.m:1623 错误代码如下: - (IBAction)deleteClick:(UIButton *)sender { NSArray *array = _mTableView.indexPa

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath不执行的问题

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath不执行基本上只有3个原因 1. delegate没设,一定要有self.tableView.delegate = self 2. section,row的个数返回为0,或者有冲突 3. tableView的frame有问题,比如位(0,0,0,0) 我遇到的问题比较奇葩,因为我喜欢在代码里添加约

UITableView UITableViewCell NSIndexPath

--------------------------------------------------------------------------NSIndexPath------------------------------------------------------------------------- 1:初始化NSIndexPath (来自: Kid) inSection 表示TableView 的分组的 第一组数据. NSIndexPath *indexPath = [NSIn

定制化的Cell, 如何获得NSIndexPath

如果button是添加到cell.contentView上面的话, UITableViewCell *cell = button.superview.superview; NSIndexPath *index = [myTableView indexPathForCell:cell]; 备注:一直向上找它的superView直到superView为UITableViewCell,最多向上N次.反正现在我这是这么处理的.此外现在自定义cell,最好把所有的元素放进cell.contentView.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;方法意思

这个方法是用来设置你的TableView中每一行显示的内容和格式的. indexPath 用来指示当前单元格,它的row方法可以获得这个单元格的行号,section方法可以获得这个单元格所处的区域号 static NSString *CellIdentifier = @"cell";//可复用单元格标识 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (ce

iOS开发——网络编程OC篇&Socket编程

Socket编程 一.网络各个协议:TCP/IP.SOCKET.HTTP等 网络七层由下往上分别为物理层.数据链路层.网络层.传输层.会话层.表示层和应用层. 其中物理层.数据链路层和网络层通常被称作媒体层,是网络工程师所研究的对象: 传输层.会话层.表示层和应用层则被称作主机层,是用户所面向和关心的内容. http协议   对应于应用层 tcp协议    对应于传输层 ip协议     对应于网络层 三者本质上没有可比性.  何况HTTP协议是基于TCP连接的. TCP/IP是传输层协议,主要

iOS开发——项目实战总结&UITableView性能优化与卡顿问题

UITableView性能优化与卡顿问题 1.最常用的就是cell的重用, 注册重用标识符 如果不重用cell时,每当一个cell显示到屏幕上时,就会重新创建一个新的cell 如果有很多数据的时候,就会堆积很多cell.如果重用cell,为cell创建一个ID 每当需要显示cell 的时候,都会先去缓冲池中寻找可循环利用的cell,如果没有再重新创建cell 2.避免cell的重新布局 cell的布局填充等操作 比较耗时,一般创建时就布局好 如可以将cell单独放到一个自定义类,初始化时就布局好