我在区分两个NSTableView时遇到问题,需要一些帮助。
我尝试过这些方法:
1.
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
if ([[notification object] tag] == 0) {
NSInteger row = [self.categoryTableView selectedRow];
...do stuff
} else {
if ([[notification object] tag] == 1 ) {
[self showItemSheet:self];
}
}
}
和2:
- (void)tableViewSelectionDidChange:(NSNotification *)notification {
if ([notification object] == categoryTableView) {
NSInteger row = [self.categoryTableView selectedRow];
..do stuff
} else {
if ([notification object] == itemTable ) {
[self showItemSheet:self];
}
}
}
这两种方法在大多数情况下都有效。但是,如果我一直从标记为0的表视图中进行选择,每单击三次或四次,就会看到itemSheet表启动。
你能尝试使用委托方法而不是通知来实现你想要的吗?从上面的代码来看,一切看起来都很好,所以错误可能在其他地方?