property 'row' not found on object of type 'NSIndexPath *' in iOS tableview

4.8k views Asked by At

I tried to fetch row id of an item with the help of "didSelectRowAtIndexPath" in iOS. Code:

   - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  

      indexPathRow=indexPath.row;  

      self.recordIdToEdit = [[[deviceNameArray objectAtIndex:indexPath.row] objectAtIndex:0] intValue];  
      NSLog(@"Item selected..%d", self.recordIdToEdit);  

     [self performSegueWithIdentifier:@"DetailsViewController" sender:nil];  

  }  

While debugging i get following error for po :

 (lldb) po [deviceNameArray objectAtIndex:indexPath.row]  
 error: property 'row' not found on object of type 'NSIndexPath *'  
 error: 1 errors parsing expression  
 (lldb) po indexPathRow  
 <nil>  

What's going wrong here? deviceNameArray is an array of string that contains result fetched from sqlite db.

3

There are 3 answers

1
Kathiravan G On BEST ANSWER

Try this while debugging we need to send int value

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{  

         int index=indexPath.row;  

          self.recordIdToEdit = [[deviceNameArray objectAtIndex:index]];  
          NSLog(@"Item selected..%d", self.recordIdToEdit);  

         [self performSegueWithIdentifier:@"DetailsViewController" sender:nil];  

      }  
1
Martijn On

Just @import UIKit; in your .h file and you'll be fine.

0
MCB On

For future reference I just got this error and it had nothing to do with indexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//...
   Task *task = [self.tasks objectAtIndex:indexPath.row];
//...
    return cell;
}

My error was that self.tasks was populated with NSDictionarys instead of Task objects.

So, at least in my case the error was misleading, if nothing else is working maybe check the type assignment.