Note that there are some explanatory texts on larger screens.

plurals
  1. PONSTableView binding problem
    primarykey
    data
    text
    <p>I have only just started with XCode (v3.2.2) and Interface Builder and have run into a problem.</p> <p>Here is what I have done:</p> <p>I have made a class to be the datasource of a NSTableView:</p> <pre><code>@interface TimeObjectsDS : NSControl { IBOutlet NSTableView * idTableView; NSMutableArray * timeObjects; } @property (assign) NSMutableArray * timeObjects; @property (assign) NSTableView * idTableView; - (id) init; - (void) dealloc; - (void) addTimeObject: (TimeObj *)timeObject; // NSTableViewDataSource Protocol functions - (int)numberOfRowsInTableView:(NSTableView *)tableView; - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row: (int)row; @implementation TimeObjectsDS @synthesize timeObjects; @synthesize idTableView; -(id) init { if (self = [super init]) { self.timeObjects = [[NSMutableArray alloc] init]; TimeObj *timeObject = [[TimeObj alloc] init]; [timeObject setProjectId:11]; [timeObject setDescription:@"Heja"]; [timeObject setRegDate:@"20100331"]; [timeObject setTimeSum:20.0]; [timeObjects addObject:timeObject]; [timeObject release]; [idTableView reloadData]; } return self; } - (void) dealloc { [idTableView release]; [timeObjects release]; [super dealloc]; } // Functions - (void) addTimeObject: (TimeObj *)timeObject { [self.timeObjects addObject:timeObject]; [idTableView reloadData]; } // NSTableViewDataSource Protocol functions - (int) numberOfRowsInTableView:(NSTableView *)tableView { return [self.timeObjects count]; } - (id) tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row { return [[timeObjects objectAtIndex:row] description]; } @end </code></pre> <p>I have then bound my NSTableView in the View to this datasource like so:</p> <p><a href="http://www.og-entertainment.com/tmp/ib_datasource_bindings_big.png" rel="nofollow noreferrer">alt text http://www.og-entertainment.com/tmp/ib_datasource_bindings_big.png</a></p> <p>I have also bound the View NSTableView to the Controller idTableView variable in Interface Builder seen above</p> <p>In the init function I add a element to the mutable array. This is displayed correctly in the NSTableView when I run the application. However when I add another element to the array (of same type as in init) and try to call <strong>[idTableView reloadData]</strong> on the View nothing happens. In fact the Controller idTableView is null. When printing the variable with <strong>NSLog</strong>(@"idTableView: %@", idTableView) I get "<strong>idTableView: (null)</strong>"</p> <p>Im runing out of ideas how to fix this. Any ideas to what I could do to fix the binding?</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.
    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