获取所有选定的单元格值

Mal*_*loc 2 uitableview ios

我的目的是当用户点击view1(进入view2)按钮时,我会将UITableView刚刚签入的所有选定单元格发送view1view2.所以在将表格传递到下一个视图之前,我想测试一下我是否在正确的轨道上,但似乎没有.这是我的代码:

-(IBAction)goToView2{
    //get all section selectioned items into an array
    themesChosed=[tView indexPathsForSelectedRows];//tView is the outlet of my UITableView and themesChosed is an NSArray declared in the .h file
    for (int i=0; i<=[themesChosed count]; i++) {
        NSLog(@"%i",[[themesChosed objectAtIndex:i]integerValue]);
    }


}
Run Code Online (Sandbox Code Playgroud)

这总是给我一个0.

2012-01-13 15:52:06.472 MyApp[876:11603] 0
Run Code Online (Sandbox Code Playgroud)

虽然我在桌子上选了几个项目.

mat*_*way 5

对象themesChosedNSIndexPath对象.您将要访问rowsection属性,如下所示:

-(IBAction)goToView2{
    //get all section selectioned items into an array
    themesChosed=[tView indexPathsForSelectedRows];//tView is the outlet of my UITableView and themesChosed is an NSArray declared in the .h file
    for (int i=0; i<=[themesChosed count]; i++) {
        NSIndexPath *thisPath = [themesChosed objectAtIndex:i];
        NSLog(@"row = %i, section = %i", thisPath.row, thisPath.section);
    }
}
Run Code Online (Sandbox Code Playgroud)