Red*_*Mak 1 macos nsarraycontroller cocoa-bindings
我正在使用可可绑定、NSArrayController 和核心数据。启动后,应用程序必须获取第一项,我在 applicationDidFinishLaunching 中尝试此操作:
1. Entity *ent = arrayManager.arrangedObjects[0];
2. Entity *ent = arrayManager.selectedObjects[0];
Run Code Online (Sandbox Code Playgroud)
---> 错误说数组为空。为什么 ?
我不明白的另一件事是,当应用程序出现时,在 tableView 中有一个选定的行,但是当我记录时:
NSLog(@"selected row in applicationDidFinishLaunching = %li",self.TableViewController.tableView.selectedRow);
Run Code Online (Sandbox Code Playgroud)
log: -1--> 没有选择行!为什么 ?
您必须在 ArrayController 上进行提取applicationDidFinishLaunching:才能在那里看到您的实体。在从 ArrayController 访问任何内容之前尝试这样做:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
NSError *error;
[arrayManager fetchWithRequest:nil merge:NO error:&error];
Entity *ent = arrayManager.arrangedObjects[0];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
561 次 |
| 最近记录: |