Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't figure out how to do this cocoa binding
    text
    copied!<p>I am a .net developer that's trying to learn how to do cocoa programming on a mac. I have run into a problem that I can't seem to figure out or find an answer for.</p> <p>I have created the following classes:</p> <ul> <li><code>ITObject</code> - subclass of NSObject</li> <li><code>ITPlayer</code> - subclass of ITObject</li> <li><code>ITEnemy</code> - subclass of ITObject</li> </ul> <p>In my <code>MainMenu.xib</code> file I have a window that contains the following controls:</p> <ul> <li><code>NSArrayController</code> - linked to App Delegate (itObjects)</li> <li><code>NSTableView</code> - linked to a NSArrayController (arrangedObjects)</li> <li><code>NSTextBox</code> - linked to the same NSArrayController (selection.player)</li> </ul> <p>itObjects is an NSMutableArray that I use to contain any ITObject classes. The NSArrayController was set to use ITObject as the class. When I add a ITPlayer to the itObjects property, the text box doesn't read the player property.</p> <p>The player property is unique to ITPlayer. If the player property is not part of the class, I want to display '<code>N/A</code>' in the text box, if it is there, I want the binding to show the value. Right now, it does nothing.</p> <p>More information on the objects:</p> <p>The code for the items looks like this:</p> <pre><code>@interface ITObject:NSObject &lt;NSCoding&gt;{ int initiativeRoll, initiativeBonus, initiativeKicker; } @property int initiativeRoll, initiativeBonus, initiativeKicker; @property (readonly) int initiativeTotal, initiativeCalc; @end </code></pre> <p>That is the header file for the ITObject (obviously). The ITEnemy and ITPlayer are setup like this (only so far).</p> <pre><code>@interface ITPLayer:ITOjbect &lt;NSCoding&gt;{ NSString *player; } @property (copy) NSString *player; @end </code></pre> <p>The init method for the ITPlayer is setup in the implementation file like this:</p> <pre><code>- (void)init{ self = [super init] if (self){ player = @"undefined"; } return self; } </code></pre> <p>There is also a initWithCoder: method, but I haven't been using that yet, so I don't think that this is suspect.</p> <p>Thank you very much for your help!</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