Xcode 要传递带有AccessoryButton标记的数据吗
我有以下代码:Xcode 要传递带有AccessoryButton标记的数据吗,xcode,uitableview,segue,Xcode,Uitableview,Segue,我有以下代码: - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { UITableViewCell *recordCell = [tableView cellForRowAtIndexPath:indexPath]; DetailViewController.record = [self recordByName:recordC
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *recordCell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController.record = [self recordByName:recordCell.textLabel.text];
它工作得很好。但是我想用RecordTableViewCell替换UITableViewCell,这样我就可以使用recordLabel而不是textLabel。
代码应该是
RecordTableViewCell *recordCell = [tableView cellForRowAtIndexPath:indexPath];
DetailViewController.record = [self recordByName:recordCell.recordLabel.text];
但它不起作用。它说不兼容的指针类型正在初始化RecordTableViewCell,表达式类型为UITableViewCell。。。
请帮忙。谢谢。只需在代码中添加一个类型转换,如下所示:
RecordTableViewCell *recordCell = (RecordTableViewCell *) [tableView cellForRowAtIndexPath:indexPath];