2011-09-12 7 views
1

私は非常に新しい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 protocolbindingsのいずれかを使用することができます

- (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; 
} 
+0

NSTableViewでプロパティリストを表現したいとは思わないでしょう。 OS Xでは、ツリーは通常NSOutlineViewで表されます。プロパティリストファイルはフラットな構造ではなく、フラットにすると問題が発生します... –

答えて

関連する問題