Why does this work
and this does not
- (id)tableView
NSTableView *)tableView
objectValueForTableColumn
NSTableColumn *)tableColumn
row
NSInteger)row
is only called when
- (NSInteger)numberOfRowsInTableView
NSTableView *)aTableView
returns a number and not the result of a method?
Code:
#import "ArduSerialAppDelegate.h"
@implementation ArduSerialAppDelegate
@synthesize window = _window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
arduino = [[Matatino alloc] initWithDelegate:self];
NSLog(@"%@", [arduino deviceNames]);
devices = [[NSMutableArray alloc] init];
[devices addObjectsFromArray:[arduino deviceNames]];
NSLog(@"devices %@", devices);
devicesTable = [[NSTableView alloc] init];
[devicesTable setDataSource:self];
[devicesTable setDelegate:self];
//[devicesTable reloadData];
}
-(void)awakeFromNib
{
[devicesTable reloadData];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return 2;
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row
{
NSLog(@"objectValueForTableColumn");
NSLog(@"devices inside objectvalue%@", [devices objectAtIndex:row]);
return [[arduino deviceNames] objectAtIndex:row];
}
- (void) receivedString:(NSString *)rx {
}
- (void) portAdded:(NSArray *)ports {
}
- (void) portRemoved:(NSArray *)ports {
}
- (void) portClosed {
}
@end
Code:
#import "ArduSerialAppDelegate.h"
@implementation ArduSerialAppDelegate
@synthesize window = _window;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
arduino = [[Matatino alloc] initWithDelegate:self];
NSLog(@"%@", [arduino deviceNames]);
devices = [[NSMutableArray alloc] init];
[devices addObjectsFromArray:[arduino deviceNames]];
NSLog(@"devices %@", devices);
devicesTable = [[NSTableView alloc] init];
[devicesTable setDataSource:self];
[devicesTable setDelegate:self];
//[devicesTable reloadData];
}
-(void)awakeFromNib
{
[devicesTable reloadData];
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [[arduino deviceNames] count];
}
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(NSInteger)row
{
NSLog(@"objectValueForTableColumn");
NSLog(@"devices inside objectvalue%@", [devices objectAtIndex:row]);
return [[arduino deviceNames] objectAtIndex:row];
}
- (void) receivedString:(NSString *)rx {
}
- (void) portAdded:(NSArray *)ports {
}
- (void) portRemoved:(NSArray *)ports {
}
- (void) portClosed {
}
@end
- (id)tableView
objectValueForTableColumn
row
is only called when
- (NSInteger)numberOfRowsInTableView
returns a number and not the result of a method?
Last edited by a moderator: