ios - 在 iOS tableview 中的类型为 'row' 的对象上找不到属性 'NSIndexPath *'

标签 ios sqlite tableview nsindexpath rowid

我试图在 iOS 中借助“didSelectRowAtIndexPath”获取项目的行 ID。 代码:

   - (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];  

  }  

调试时出现以下错误:

 (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>  

这里出了什么问题? deviceNameArray 是一个字符串数组,包含从 sqlite 数据库中获取的结果。

最佳答案

在调试时试试这个,我们需要发送 int 值

- (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];  

      }  

关于ios - 在 iOS tableview 中的类型为 'row' 的对象上找不到属性 'NSIndexPath *',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27010479/

相关文章:

ios - 对 bindTo 的模糊引用

ios - 通过 NSDate 对象属性快速过滤

ios - 从 Firebase JSON 获取图像

java - UpdateString 未由 SQLite JDBC 驱动程序实现

ios - 如何通过快速按下标签来显示/隐藏标签?

ios - iOS 栏按钮项目中的动态文本

android - 未在 recyclerview 中检索来自 SQLite 的数据

sqlite - 如何建立外键默认启用的sqlite?

ios - 使用 swift 从 parse.com 将数据和图像查询到 TableView 中

android - 如何在 TableRow 的一个单元格中添加超过 1 个 View ?