NSTableView with plist file

2019-03-02 07:33发布

I am very new to mac app development. so just doing some practical exercise.

I want to create a tableview which display data from my plist file.
I have one windowcontroller class and window controller.xib file.
I drag and drop NSTableView to the .xib file.
and using this code to load plist file

- (void)windowDidLoad
{
    [super windowDidLoad];

    NSBundle *bundle = [NSBundle mainBundle];
    NSString *path = [bundle pathForResource:@"tenth" ofType:@"plist"];
    file = [[NSArray alloc] initWithContentsOfFile:path];

}

Now what should i do for displaying rows in my tableview??
Which method i have to use? and how??

like in IOS development we are using

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

NSArray *temp = [file objectAtIndex:indexPath.row];
cell.textLabel.text = [temp objectAtIndex:0];
return cell;
}

1条回答
我命由我不由天
2楼-- · 2019-03-02 08:32

You can use either bindings with an NSArrayController or implement the NSTableViewDataSource protocol.

Recommended reading: Table View Programming Guide.

查看更多
登录 后发表回答