
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to create NSIndexPath for TableView in iOS?
Index path is generally a set of two values representing row and section of a table view. Index path can be created in objective C as well as Swift as both are native language of iOS Development.
IndexPathForRow is a class method in iOS. To create a index path we need to be sure about the section and row we need to create. Below are the methods of creating an Indexpath.
To create an IndexPath in objective C we can use.
NSIndexPath *myIP = [NSIndexPath indexPathForRow: Int inSection:Int] ;
Example
NSIndexPath *myIP = [NSIndexPath indexPathForRow: 5 inSection: 2] ;
To create an IndexPath in Swift we can use.
IndexPath(row: rowIndex, section: sectionIndex)
Example
IndexPath(row: 2, section: 4)
Both of these are generally used in Cell for row at method, which can be used as
let cell = tblView.cellForRow(at: IndexPath(row: 5, section: 2)
- Related Articles
- How do I create a TableView with rounded corners in iOS?
- How to change background color of TableView items on iOS?
- How to create a TableView in JavaFX?
- How to create a WebView in iOS/iPhone?
- How to create CollectionView Layout in an iOS App?
- How to create Picker programmatically from array in iOS?
- How to create scrollable TextView on iOS App?
- How to add data to a TableView in JavaFX?
- How to create Tab Bar Layout in an iOS App?
- How to Set opacity for View in iOS?
- How to create transparent Status Bar and Navigation Bar in iOS?
- How to create a WebView in an iOS App using Swift?
- How to renew distribution certificate for iOS?
- How to set background for Navigation Bar in iOS?
- Create circular Progress Bar in iOS

Advertisements