Note that there are some explanatory texts on larger screens.

plurals
  1. POthe programmatic equivalent of binding an nsarraycontroller to a nsobjectcontroller, selection, content
    text
    copied!<p>i've split up my UI into various nib files.</p> <p>now, i use two <code>nswindowcontroller</code> subclasses with <code>nsarraycontroller</code> and <code>nsobjectcontroller</code> IBOutlets. The nwwindowcontrollers are the File's Owner in their respective nibs.</p> <p>the controllers are assigned in IntefaceBuilder (IB).</p> <p>previously in the one nib, i had a binding from an employees <code>nsarraycontroller</code> to a single employee <code>nsobjectcontroller</code>, using a controllerkey of 'selection' and modelkeypath of 'self'</p> <p>now, i try to 'bind' them via code, as such</p> <pre><code>- (IBOutlet) showEmployeeWindow:(id)sender; //load a window from a nib file. ... // Get the employee arraycontroller. NSArrayController *employeesController = [employeesWindowController employeeArrayController]; // Get the selected employee from the employeeS controller id employee = [empController selection]; //now the employee NSObjectController *emplController = [singleEmployeeWindowController employeeController]; //Set the content object of the employee controller as the nsset called employees. [emplController setContent: employee]; //Show the window. [singleEmployeeWindowController showWindow:sender]; ... </code></pre> <p>}</p> <p>The problem.</p> <p>the debug does shows that a different memory address for the selected employee. ie, the line</p> <pre><code>id employee = [empController selection]; // Get the selected employee from the employeeS controller </code></pre> <p>seems to get a different employee.</p> <p>but i consistently see the first employee never the selected one.</p> <p>the selected employee is never set as the content -- or more precisely the selected employee doesnt replaces the default first one.</p> <p>Note that each <code>nswindowcontroller</code> has a <code>nsmanagedobject</code> context set via the nsdocument. its the File's Owner in the nib.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload