私は非常に新しいMacアプリケーション開発です。ちょうど実践的な運動をしています。plistファイル付きNSTableView
私のplistファイルのデータを表示するテーブルビューを作成したいと思います。
私は一つの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の開発のように、我々はあなたがNSArrayController
またはimplement the NSTableViewDataSource
protocolでbindingsのいずれかを使用することができます
- (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;
}
NSTableViewでプロパティリストを表現したいとは思わないでしょう。 OS Xでは、ツリーは通常NSOutlineViewで表されます。プロパティリストファイルはフラットな構造ではなく、フラットにすると問題が発生します... –