I m 制作“模拟”至单列项目,在公路上投入少数ump。 问题在于,我的NSTableView是NOT,显示了NSMutableArray“myArray”的数据,我不知道为什么。 谁能指出我的错误?
/*
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