所以我创建了一个函数:
-(void)checkCount:(UITableView *)tableView isIndexPathChecked:(NSIndexPath *)indexPath{
NSString *name = [[NSString alloc] init];
UITableViewCell *investigatedCell = [tableView cellForRowAtIndexPath:indexPath];
if(investigatedCell.accessoryType ==UITableViewCellAccessoryCheckmark)
name = investigatedCell.textLabel.text;
[checkedRows addObject: name];
}
每次尝试从另一个方法中调用此方法时,我都会收到错误。正确的语法是什么?谢谢。
最佳答案
我相信您看到的错误是因为您的公共(public)头文件中不存在该方法调用。尝试添加
-(void)checkCount:(UITableView *)tableView isIndexPathChecked:(NSIndexPath *)indexPath;
到您的 .h 文件。
您可能还需要仔细检查拼写并绝对确定将方法调用发送到正确的对象。我猜是我自己。
UITableView *myTable = pointer_to_tableView_instance;
NSIndexPath *indexPath = pointer_to_indexPath_to_check;
[self checkCount:myTable isIndexPathChecked:indexPath];
NSLog(@"%i",checkedRows.count);
关于iphone - 尝试创建函数来计算选中单元格的数量并从另一个函数调用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11234328/