iOS Developer Library

Developer

UIKit Framework Reference NSIndexPath UIKit Additions

Options
Deployment Target:

On This Page
Language:

NSIndexPath

Inherits From


Not Applicable

Conforms To


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 2.0 and later

The UIKit framework adds programming interfaces to the NSIndexPath class of the Foundation framework to facilitate the identification of rows and sections in UITableView objects and the identification of items and sections in UICollectionView objects.

The API consists of class factory methods and properties for accessing the various indexed values. You use the factory methods to create an index path for the corresponding table view or collection view.

  • Returns an index-path object initialized with the indexes of a specific row and section in a table view.

    Declaration

    Swift

    init!(forRow row: Int, inSection section: Int) -> NSIndexPath

    Objective-C

    + (NSIndexPath *)indexPathForRow:(NSInteger)row inSection:(NSInteger)section

    Parameters

    row

    An index number identifying a row in a UITableView object in a section identified by section.

    section

    An index number identifying a section in a UITableView object.

    Return Value

    An NSIndexPath object or nil if the object could not be created.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later

  • Returns an index-path object initialized with the indexes of a specific item and section in a collection view.

    Declaration

    Swift

    init!(forItem item: Int, inSection section: Int) -> NSIndexPath

    Objective-C

    + (NSIndexPath *)indexPathForItem:(NSInteger)item inSection:(NSInteger)section

    Parameters

    item

    An index number identifying an item in a UICollectionView object in a section identified by the section parameter.

    section

    An index number identifying a section in a UICollectionView object.

    Return Value

    An NSIndexPath object or nil if the object could not be created.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later

  • section section Property

    An index number identifying a section in a table view or collection view. (read-only)

    Declaration

    Swift

    var section: Int { get }

    Objective-C

    @property(nonatomic, readonly) NSInteger section

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later

  • row row Property

    An index number identifying a row in a section of a table view. (read-only)

    Declaration

    Swift

    var row: Int { get }

    Objective-C

    @property(nonatomic, readonly) NSInteger row

    Discussion

    The section the row is in is identified by the value of section.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later

  • item item Property

    An index number identifying an item in a section of a collection view. (read-only)

    Declaration

    Swift

    var item: Int { get }

    Objective-C

    @property(nonatomic, readonly) NSInteger item

    Discussion

    The section the item is in is identified by the value of section.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 6.0 and later