Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Isnt it often the case. after 2 days of pulling your hair out. ask a question and bang the answer comes within 1/2 hour.</p> <p>So the secret is essentially cocoa bindings, and specifically <a href="https://developer.apple.com/library/mac/#documentation/cocoa/reference/ApplicationKit/Protocols/NSKeyValueBindingCreation_Protocol/Reference/Reference.html" rel="nofollow noreferrer">Key Value Bindings</a></p> <p>That documentation is the typical yackademic yadda yadda. The cascading clue actually came from <a href="https://stackoverflow.com/questions/2961783/how-can-i-write-cocoa-bindings-as-code-instead-of-in-the-interface-builder">a similar stack overflow question</a></p> <p>So all one needs to do is link the two controllers together like this.</p> <pre><code>NSArrayController *source = [employeesWindowController employeeArrayController]]; NSObjectController *destination = [singleEmployeeWindowController employeeController]; [destination bind:@"contentObject" toObject:source withKeyPath:@"selection.self" options:nil]; </code></pre> <p>The syntax follows that of the Interface Builder bindings. </p> <pre><code>Bind to: Content Object Content Key: selection ModelKeyPath: self </code></pre> <p>So its a darn easy one liner.</p> <p>Binding a <code>NSLabel</code> to a Controller. In IB</p> <pre><code>Bind to: Value Content Key: selection ModelKeyPath: name </code></pre> <p>In code,</p> <pre><code>[label bind:@"value" toObject:controllerRef withKeyPath:@"selection.name" options:nil]; </code></pre> <p>And the options mimic those of "Raises for Not Applicable Keys" and so forth. See yackademic text for the details.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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