Why is tableView:objectValueForTableColumn:row: not being called?

Discussion in 'Mac Programming' started by NSNick, Nov 26, 2011.

  1. NSNick, Nov 26, 2011
    Last edited by a moderator: Nov 27, 2011

    macrumors regular

    Joined:
    Jun 27, 2008
    Location:
    Washington D.C.
    #1
    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
    
     
  2. macrumors 68000

    Sydde

    Joined:
    Aug 17, 2009
    #2
    Why are you creating an object that is already an IBOutlet in -init?
     

Share This Page