PDA

View Full Version : Why is tableView:objectValueForTableColumn:row: not being called?




NSNick
Nov 26, 2011, 03:25 PM
#import <AppKit/AppKit.h>

@interface ReceivedData : NSObject <NSTableViewDataSource>
{
NSMutableArray *receivedStrings;
IBOutlet NSTableView *stringsTableView;
}

-(void)addString:(NSString *)s;
@end



#import "ReceivedData.h"

@implementation ReceivedData

- (id)init
{
self = [super init];
if (self) {
receivedStrings = [[NSMutableArray alloc] init];
stringsTableView = [[NSTableView alloc] init];
[stringsTableView setDataSource:self];
}

return self;
}

-(void)addString:(NSString *)s
{
NSLog(@"Received String: %@", s);
[receivedStrings addObject:s];
NSLog(@"%@", receivedStrings);
[stringsTableView reloadData];
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView
{
NSLog(@"numberOfRowsInTableView called");
NSLog(@"%d rows", [receivedStrings count]);
return [receivedStrings count];
}


- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
NSLog(@"objectValueForTableColumn:row: called");
return [receivedStrings objectAtIndex:row];
}

@end



Sydde
Nov 26, 2011, 11:18 PM
Why are you creating an object that is already an IBOutlet in -init?