NSTableView is not showing my data. Why is that happening?
Posted
by lampShade
on Stack Overflow
See other posts from Stack Overflow
or by lampShade
Published on 2010-04-23T00:58:52Z
Indexed on
2010/04/23
1:03 UTC
Read the original article
Hit count: 369
I'm making a "simple" to-do-list project and running into a few bumps in the road. The problem is that my NSTableView is NOT showing the data from the NSMutableArray "myArray" and I don't know why that is. Can someone point out my mistake?
/*
IBOutlet NSTextField *textField;
IBOutlet NSTabView *tableView;
IBOutlet NSButton *button;
NSMutableArray *myArray;
*/
#import "AppController.h"
@implementation AppController
-(IBAction)addNewItem:(id)sender
{
NSString *myString = [textField stringValue];
NSLog(@"my stirng is %@",myString);
myArray = [[NSMutableArray alloc] initWithCapacity:100];
[myArray addObject:myString];
}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [myArray count];
}
- (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
return [myArray objectAtIndex:rowIndex];
}
-(id)init
{
[super init];
[tableView setDataSource:self];
[tableView setDelegate:self];
NSLog(@"init");
return self;
}
@end
© Stack Overflow or respective owner