开发者

NSTableView with plist file

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 f开发者_JAVA百科or 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;
}


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

Recommended reading: Table View Programming Guide.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜