API参考Foundation

NSIndexPath

索引路径(常用于 Table/Collection 的 section/row/item)。

NSIndexPath 表示一个由多个索引组成的“路径”。在 UIKit 里最常见的用法是表示表格/集合视图的 sectionrow/item

类成员 (Class members)

indexPathWithIndex

从单个索引创建路径。

static indexPathWithIndex(index: number): NSIndexPath

Parameters:

NameTypeDescription
indexnumber索引。

Return Value:

  • NSIndexPath: 新路径。

indexPathWithIndexesLength

从索引数组与长度创建。

static indexPathWithIndexesLength(indexes: any, length: number): NSIndexPath

Parameters:

NameTypeDescription
indexesany索引序列。
lengthnumber长度。

Return Value:

  • NSIndexPath: 新路径。

indexPathForRowInSection

创建 TableView 常用的 row/section 路径。

static indexPathForRowInSection(row: number, section: number): NSIndexPath

Parameters:

NameTypeDescription
rownumber行索引。
sectionnumber段索引。

Return Value:

  • NSIndexPath: 新路径。

indexPathForItemInSection

创建 CollectionView 常用的 item/section 路径。

static indexPathForItemInSection(item: number, section: number): NSIndexPath

Parameters:

NameTypeDescription
itemnumber项索引。
sectionnumber段索引。

Return Value:

  • NSIndexPath: 新路径。

实例成员 (Instance members)

length

路径中索引个数。

length(): number

Return Value:

  • number: 索引个数。

indexAtPosition

取指定位置的索引。

indexAtPosition(position: number): number

Parameters:

NameTypeDescription
positionnumber位置。

Return Value:

  • number: 该位置索引。

getIndexes

将索引写入 C 数组。

getIndexes(indexes: any): void

Parameters:

NameTypeDescription
indexesany目标数组。

Return Value:

  • 无。

compare

与另一路径比较。

compare(otherObject: NSIndexPath): number

Parameters:

NameTypeDescription
otherObjectNSIndexPath另一路径。

Return Value:

  • number: 比较结果。

indexPathByAddingIndex

在末尾追加索引得到新路径。

indexPathByAddingIndex(index: number): NSIndexPath

Parameters:

NameTypeDescription
indexnumber要追加的索引。

Return Value:

  • NSIndexPath: 新路径。

indexPathByRemovingLastIndex

移除最后一个索引得到新路径。

indexPathByRemovingLastIndex(): NSIndexPath

Return Value:

  • NSIndexPath: 新路径。

相关

  • UIKit:UITableView / UICollectionView(待补齐)
头文件API清单

正在加载...

协议:JSBNSIndexPath,来源:-