Hello I am currently making my first mac app and I would like to know how can I add item to the NSTableview I already made the datasource thing here is the code
TableDataSource.h
TableDataSource.m
And here is the code where I try to add the item,
I was wondering whats wrong as I don't see it there when I try to add, do I have to implement the additemwithtitle method inside my datasource class?
TableDataSource.h
Code:
//
// TableDataSource.h
// Macohjelma
//
// Created by Samuli Lehtonen on 29.5.2010.
// Copyright 2010 Test. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface TableDataSource : NSObject {
@private
NSArray *aBuffer;
}
@end
TableDataSource.m
Code:
//
// TableDataSource.m
// Macohjelma
//
// Created by Samuli Lehtonen on 29.5.2010.
// Copyright 2010 Test. All rights reserved.
//
#import "TableDataSource.h"
@implementation TableDataSource
- (id) tableView:(NSTableView *) aTableView
objectValueForTableColumn:(NSTableColumn *) aTableColumn
row:(int) rowIndex
{
return [aBuffer objectAtIndex:rowIndex];
}
- (int)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [aBuffer count];
}
@end
And here is the code where I try to add the item,
Code:
[Notes setDataSource:DataSource];
[DataSource addItemWithTitle:@"Hello"];
[Notes reloadData];
I was wondering whats wrong as I don't see it there when I try to add, do I have to implement the additemwithtitle method inside my datasource class?