NSTableView binding problem

Posted by Niklas Ottosson on Stack Overflow See other posts from Stack Overflow or by Niklas Ottosson
Published on 2010-04-29T12:21:44Z Indexed on 2010/04/29 12:27 UTC
Read the original article Hit count: 449

Filed under:
|
|

I have only just started with XCode (v3.2.2) and Interface Builder and have run into a problem.

Here is what I have done:

I have made a class to be the datasource of a NSTableView:

@interface TimeObjectsDS : NSControl {
  IBOutlet NSTableView * idTableView;
  NSMutableArray * timeObjects;
}
@property (assign) NSMutableArray * timeObjects;
@property (assign) NSTableView * idTableView;

- (id) init;
- (void) dealloc;

- (void) addTimeObject: (TimeObj *)timeObject;
- (int) count;

// NSTableViewDataSource Protocol functions
- (int)numberOfRowsInTableView:(NSTableView *)tableView;
- (id)tableView:(NSTableView *)tableView 
            objectValueForTableColumn:(NSTableColumn *)tableColumn row:
            (int)row;

I have then bound my NSTableView in the View to this datasource like so:

alt text

I have also bound the View NSTableView to the Model idTableView variable in Interface Builder seen above

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 [idTableView reloadData] on the View nothing happens. In fact the Model idTableView is null. When printing the variable with NSLog(@"idTableView: %@", idTableView) I get "idTableView: (null)"

Im runing out of ideas how to fix this. Any ideas to what I could do to fix the binding?

© Stack Overflow or respective owner

Related posts about cocoa-bindings

Related posts about objective-c