我有两个独立的类 FirstController 和 SecondController,用故事板创建。问题是我想从 FirstController 调用 SecondController.m 中的方法。例如。:
第二控制器.m
-(void)myMethod:(CGPoint)pt {...} // It's important that there is a paramterer
第一控制器.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
// Call myMethod
}
如何以最简单的方式做到这一点?
更新: 我想使用来自“aBilal17”链接的通知:
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"updateLeftTable"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkRes:) name:@"updateLeftTable" object:nil];
(..)
-(void)checkRes:(NSNotification *)notification
{
if ([[notification name] isEqualToString:@"updateLeftTable"])
{
[myMethod ?
}
}
在其他班级:
[[NSNotificationCenter defaultCenter] postNotificationName:@"updateLeftTable" object:self];
但是现在,如何使用这个来传递我的 CGPoint 参数?