문제

I am having a problem differentiating between two NSTableViews and could use some help.

I have tried these approaches:

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];
        }
    }
}

and 2:

- (void)tableViewSelectionDidChange:(NSNotification *)notification {

    if ([notification object] == categoryTableView) {
        NSInteger row = [self.categoryTableView selectedRow];

        ..do stuff

    } else {

        if ([notification object] == itemTable ) {
            [self showItemSheet:self];
        }
    }
}

Both approaches work - most of the time. However, if I keep selecting from the tableview with tag 0, every three or four clicks and I see the itemSheet table initiated.

도움이 되었습니까?

해결책

Can you try using a delegate method instead of the notification to achieve what you want? From the code above everything looks fine so probably the error is elsewhere?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top