NSIndexPath Class Reference
| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/Foundation.framework |
| Availability | Available in iOS 2.0 and later. |
| Companion guide | |
| Declared in | NSIndexPath.h |
Overview
The NSIndexPath class represents the path to a specific node in a tree of nested array collections. This path is known as an index path.
Each index in an index path represents the index into an array of children from one node in the tree to another, deeper, node. For example, the index path 1.4.3.2 specifies the path shown in Figure 1.
1.4.3.2
Adopted Protocols
Class Methods
indexPathWithIndex:
Creates an one-node index path.
Parameters
- index
Index of the item in node 0 to point to.
Return Value
One-node index path with index.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
NSIndexPath.hindexPathWithIndexes:length:
Creates an index path with one or more nodes.
Parameters
- indexes
Array of indexes to make up the index path.
- length
Number of nodes to include in the index path.
Return Value
Index path with indexes up to length.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
NSIndexPath.hInstance Methods
compare:
Indicates the depth-first traversal order of the receiving index path and another index path.
Parameters
- indexPath
Index path to compare.
This value must not be
nil. If the value isnil, the behavior is undefined.
Return Value
The depth-first traversal ordering of the receiving index path and indexPath.
NSOrderedAscending: The receiving index path comes before indexPath.NSOrderedDescending: The receiving index path comes after indexPath.NSOrderedSame: The receiving index path and indexPath are the same index path.
Availability
- Available in iOS 2.0 and later.
Declared In
NSIndexPath.hgetIndexes:
Copies the objects contained in the index path into indexes.
Parameters
- indexes
Pointer to a C array of objects of size at least the length of the index path. On return, the index path’s indexes.
Discussion
It is the developer’s responsibility to allocate the memory for the C array.
Availability
- Available in iOS 2.0 and later.
Declared In
NSIndexPath.hindexAtPosition:
Provides the index at a particular node in the index path.
Parameters
- node
Index value of the desired node. Node numbering starts at zero.
Return Value
The index value at node or NSNotFound if the node is outside the range of the index path.
Availability
- Available in iOS 2.0 and later.
Declared In
NSIndexPath.hindexPathByAddingIndex:
Provides an index path containing the indexes in the receiving index path and another index.
Parameters
- index
Index to append to the index path’s indexes.
Return Value
New NSIndexPath object containing the receiving index path’s indexes and index.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
NSIndexPath.hindexPathByRemovingLastIndex
Provides an index path with the indexes in the receiving index path, excluding the last one.
Return Value
New index path with the receiving index path’s indexes, excluding the last one.
Discussion
Returns an empty NSIndexPath instance if the receiving index path’s length is 1 or less.
Special Considerations
On OS X v10.4 this method returns nil when the length of the receiving index path is 1 or less. On iOS and OS X v10.5 and later this method will never return nil.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
NSIndexPath.hinitWithIndex:
Initializes an allocated NSIndexPath object with a one-node index path.
Parameters
- index
Index of the item in node 0 to point to.
Return Value
Initialized NSIndexPath object representing a one-node index path with index.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
NSIndexPath.hinitWithIndexes:length:
Initializes an allocated NSIndexPath object with an index path of a specific length.
Parameters
- indexes
Array of indexes to make up the index path.
- length
Number of nodes to include in the index path.
Return Value
Initialized NSIndexPath object with indexes up to length.
Availability
- Available in iOS 2.0 and later.
See Also
Declared In
NSIndexPath.hlength
Provides the number of indexes in the index path.
Return Value
Number of indexes in the index path.
Availability
- Available in iOS 2.0 and later.
Declared In
NSIndexPath.h© 2011 Apple Inc. All Rights Reserved. (Last updated: 2011-03-08)