Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

NSNick

macrumors regular
Original poster
Jun 27, 2008
162
0
Washington D.C.
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:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.