2013-01-22 51 views
0

我怎麼可以在NSTableView使用Cocoa使用NSMutableArrayNSMutableDictionary's?任何人都可以提出適當的解決方案嗎?NSDictionary內容NSTableView

+0

http://stackoverflow.com/questions/4081632/how-to-bind-data-to-a-nstableview-from-a-nsdictionary – iPatel

+0

你打算使用綁定還是編碼? –

+0

換句話說,Cocoa Bindings或者編寫自己的控制器代碼? – paulmelnikow

回答

0

請看下面的例子:

- (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]; 
    } 

    // I will use tempDict Object for your understandings, otherwise it can be used directly. Here array1 is Main DataSource for UITableView. 
    NSDictionary *tempDict = [array1 objectAtIndex:indexPath.row]; 

    // key1 is the key to get the object from the dictionary. 
    cell.title.text = [tempDict valueForKey:key1]; 

    return cell; 
} 

這裏,陣列1是你的表視圖,其中包含NSDictionary對象主要DataSource

希望這會有所幫助。

+0

謝謝你。它真的幫了我很多:) – Preethi

+0

如果它解決了你的問題,請點擊答案旁邊的複選標記輪廓。 – paulmelnikow