以编程方式将 NSComboBox 绑定到 NSArrayController
我无法填充 NSComboBox
。我正在尝试以编程方式将其绑定到 NSArrayController:
frequencyArrayController = [[NSArrayController alloc] initWithContent:nil];
[frequencyArrayController setManagedObjectContext:[[NSApp mainWindowDocument] managedObjectContext]];
[frequencyArrayController setEntityName:@"Frequency"];
[frequencyArrayController fetch:self];
[frequencyComboBox bind:@"contentValues" toObject:frequencyArrayController withKeyPath:@"arrangedObjects.DisplayName" options:nil];
我缺少什么?
该字段位于 NSPanel
上,应用启动时尚未打开。我正在绑定它并提前加载笔尖,这是一个问题吗?
I can't populate a NSComboBox
. I'm trying to bind it programmatically to an NSArrayController
:
frequencyArrayController = [[NSArrayController alloc] initWithContent:nil];
[frequencyArrayController setManagedObjectContext:[[NSApp mainWindowDocument] managedObjectContext]];
[frequencyArrayController setEntityName:@"Frequency"];
[frequencyArrayController fetch:self];
[frequencyComboBox bind:@"contentValues" toObject:frequencyArrayController withKeyPath:@"arrangedObjects.DisplayName" options:nil];
What am I missing?
The field is on a NSPanel
which is not open yet when the app starts. I'm binding it and loading the nib in advance, is this an issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要告诉您的数组控制器在某个时刻获取:。
编辑:这是我用来测试的示例代码:
检查您的 MOC 和 IBOutlet 是否为非零。
You need to tell your array controller to fetch: at some point.
Edit: Here's the example code I'm using to test:
Check that your MOC and IBOutlets are non-nil.