-2

I am trying to get the "row" value from indexPathsForSelectedRows.

NSArray *selectedCells = [self.storeTableView indexPathsForSelectedRows];
NSLog(@"%@",[selectedCells objectAtIndex:0]);

This NSLog prints out

<NSIndexPath: 0xc000000000008016> {length = 2, path = 0 - 4}

How can I just get the number '4' as an integer in this example?

I've tried objectForKey@"path". but it did not work.

Eric Chuang
  • 1,017
  • 9
  • 28
  • 1
    You should consult the [NSIndexPath UIKit Additions](https://developer.apple.com/library/ios/documentation/UIKit/Reference/NSIndexPath_UIKitAdditions/index.html#//apple_ref/doc/uid/TP40007175) reference. – Mick MacCallum May 29 '15 at 14:07
  • Use this NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow]; and get this as selectedIndexPath.row – LC 웃 May 29 '15 at 14:13

1 Answers1

3

You can do

NSArray *selectedCells = [self.storeTableView indexPathsForSelectedRows];
NSIndexPath *firstIndexPath = [selectedCells objectAtIndex:0];
NSUInteger row = firstIndexPath.row

and row will be 4 in your case.

Leo
  • 24,596
  • 11
  • 71
  • 92
Schemetrical
  • 5,506
  • 2
  • 26
  • 43