Code:
#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
Last edited by a moderator: