2

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

  }  

デバッグ中に 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>  

ここで何がうまくいかないのですか?deviceNameArray は、sqlite db から取得した結果を含む文字列の配列です。

4

3 に答える 3

3

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

      }  
于 2014-11-19T07:00:18.317 に答える
0

将来の参考のために、私はこのエラーを受け取りましたが、それは何の関係もありませんでしたindexPath

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

私のエラーは、 Task オブジェクトの代わりに sself.tasksが入力されていたことです。NSDictionary

したがって、少なくとも私の場合、エラーは誤解を招くものでした。他に何も機能していない場合は、型の割り当てを確認してください。

于 2015-07-02T02:18:45.520 に答える