我使用xib创建名为MyTBViewController的NSViewController的子类,并向xib添加NSTableView。但当我将NSTableView的委托连接到File的所有者并运行应用程序时,它告诉我:EXC_BAD_ACCESS .....
在Appdelegate.m中:
- (void)awakeFromNib{
MyTBViewController *weatherVC = [[[MyTBViewController alloc] init] autorelease];
NSMenuItem *item = [[[NSMenuItem alloc] init] autorelease];
[item setView:weatherVC.view];
NSMenu *menu = [[[NSMenu alloc] initWithTitle:@"M"] autorelease];
[menu addItem:item];
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
[statusItem setImage:[NSImage imageNamed:@"statusIcon"]];
[statusItem setAlternateImage:[NSImage imageNamed:@"statusIcon"]];
[statusItem setHighlightMode:YES];
[statusItem setMenu:menu];
}
如何设置NSTableView的委托?