【发布时间】:2017-02-22 06:29:38
【问题描述】:
我有两个视图控制器,分别是 ViewControllerA 和 ViewControllerB。
在 ViewcontrollerB 上有 tableview 单元格。单击表格视图单元格时,我想将在 ViewControllerB 上选择的数据发送到 ViewControllerA 上的标签。
我知道它可以通过多种方式实现,但是如何通过块来实现。请建议。
提前致谢!
视图控制器 B
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *viewArr = [self.array objectAtIndex:indexPath.row];
NSLog(@"the value obtained on cell is %@",viewArr);
ViewController *vc=[[ViewController alloc]init];
vc.aSimpleBlock(viewArr);
}
【问题讨论】:
-
在块中我们也可以用多种方式做 int,你能展示你尝试过的代码
-
我还没有通过块实现它,我已经使用委托完成了它......但现在我想通过块实现同样的......但无法理解正确的实现方式。
-
好的,我添加一些示例
-
你也可以使用 NSNotifications。
标签: ios objective-c uitableview objective-c-blocks