iphone - 尝试创建函数来计算选中单元格的数量并从另一个函数调用它

标签 iphone objective-c function uitableview methods

所以我创建了一个函数:

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

相关文章:

function - 如何使用flutter和firebase实时数据库发送fcm通知

iphone - 背景图像尺寸 iPhone

iphone - 为什么我的 UIViewController 不在其 View 的响应者链中?

iphone - ipad 中的 SplitView 导航问题

objective-c - Objective-C 的国际复数化库?

javascript - javascript中数组方法和join函数组合输出无法理解

javascript - “OnClick”功能在第一次点击时未运行,需要第二次点击

iPhone iOS 如何计算字符串中不区分大小写的单词出现次数?

带有类别的 iPhone 全局类,这是正确的吗?

objective-c - 从内部循环访问NSMutableArray