私はMacアプリ開発に非常に慣れていません。実践的な演習を行うだけです。
plist ファイルのデータを表示するテーブルビューを作成したいと考えています。
1 つの windowcontroller クラスと window controller.xib ファイルがあります。
NSTableView を .xib ファイルにドラッグ アンド ドロップします。
このコードを使用してplistファイルをロードします
- (void)windowDidLoad
{
[super windowDidLoad];
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle pathForResource:@"tenth" ofType:@"plist"];
file = [[NSArray alloc] initWithContentsOfFile:path];
}
テーブルビューに行を表示するにはどうすればよいですか??
どの方法を使用する必要がありますか? そしてどうやって??
私たちが使用しているIOS開発のように
- (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;
}