如何设置NSTableView委托&数据源?

时间:2013-05-17 06:33:25

标签: macos nstableview xib

我使用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];

}

enter image description here

如何设置NSTableView的委托?

0 个答案:

没有答案
相关问题