-2

I have a tableview structure like this,

Section 1

----> Row 1

----> Row 2

----> Row 3

Section 2

----> Row 1

----> Row 2

Section 3

----> Row 1

----> Row 2

----> Row 3

----> Row 4

How to get index of particular row that I have to pass, like i have to get index of 2nd row from 3rd section ? Consider I have to pass exact address/index/location of 2nd row from 3rd section.

iOSNoob
  • 1,420
  • 2
  • 16
  • 30
  • at which point do you want to get it?? – Mohd Prophet Feb 16 '15 at 11:50
  • what exactly do you mean with `get index of particular row`? do you want to create the `NSIndexPath` for that instance? – nburk Feb 16 '15 at 11:51
  • Making more simple if I have to pass index of row to mutable array like this, [courseIds objectAtIndex:indexPath.row]; where courseIds is my mutable array. – iOSNoob Feb 16 '15 at 12:15

2 Answers2

1

You can create a subclass of UITableViewCell, and add two properties to it

@property (nonatomic) NSInteger row;
@property (nonatomic) NSInteger section;

then in the cellForRowAtIndexPath: method you can set these values according to the index path.

and once you want to pass the row&section info just use delegation or KVO

YYfim
  • 1,402
  • 1
  • 9
  • 24
0
  • indexPathForRow:inSection: Returns an index-path object initialized with the indexes of a specific row and section in a table view.

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/NSIndexPath_UIKitAdditions/index.html#//apple_ref/occ/clm/NSIndexPath/indexPathForRow:inSection:

nspavlo
  • 377
  • 3
  • 12