开发者

NSArrayController + Core Data + Bindings

开发者 https://www.devze.com 2023-01-24 19:19 出处:网络
I have one window containing an NSTableView listing a bunch of managed objects. I can right click a selection of those objects, and bring up an edit window to edit the properties of those objects (in

I have one window containing an NSTableView listing a bunch of managed objects. I can right click a selection of those objects, and bring up an edit window to edit the properties of those objects (in theory).

Here's my code to bring up the window:

EditObjController *editObjController = [[EditObjController alloc] init];

// This line has to be first or the properties of editObjController are all nil.
[[editObjController window] makeKeyAndOrderFront:self]; 
[editobjController.arrayController setManagedObjectContext:[[NSApp delegate] managedObjectContext]];

NSArray *selection = [_objects objectsAtIndexes: [_objectsTableView selectedRowIndexes]];
[editObjController.arrayController setContent: selection];

My nib for the editing window has an NSArrayController in it. I have various textfields on the window, all of which are bound to the NSArrayController, controller key 'selection', with model key path=nameoffield.

The array controller is a valid object. No errors are reported.

All that comes up when the window appears is 'No selection' in all the textfields. What am I missing? I've googled extensively and I can't fi开发者_高级运维nd a decent tutorial that explains how to actually edit records using Core Data and Bindings.


Your NSTableView and Edit Window should share the same array controller.

0

精彩评论

暂无评论...
验证码 换一张
取 消