Data Sources and NSTableView

I know that table sources need a data source to store the data that will be displayed in the table. Lets say that I'm going to make my AppController a data source of my table view and that I am creating a connection in the interface builder. My question is that my actual data will be stored in an array, let myArray call it when I set the data source in the code, should I do it

 [tableView setDataSource:myArray]; or this [tableView setDataSource:self];

I am confused by this. setting the data source using the keyword "i" installed it in the AppController, if I'm not mistaken.

+3
source share
1 answer

NSTableViewDataSource ( NSTableDataSource 10.6).

NSArray , .

AppController AppController .

- (void)applicationDidFinishLaunching:(NSNotification*)notification
{
    [tableView setDataSource:self];
}

- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
    return [myArray count];
}

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
    return [myArray objectAtIndex:rowIndex];   
}
+7

Source: https://habr.com/ru/post/1742192/


All Articles