2010-06-25 75 views
0

我用NSDictionary和dictionaryWithContentsOfFile plist填充UITableView。iPhone表格視圖,使用NSDictionary&plist

在plist中我有3行,每行都有一個數組。

我不知道該行的id/index是什麼。

下:

// Customize the appearance of table view cells. 
- (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]; 
    } 

    // Configure the cell. 
    cell.textLabel.text = @"Blah"; 
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 
    return cell; 
} 

對於cell.textLabel.text,我怎麼做這樣的事情[self.myList信息getKey] getKey將返回行的鍵/ id?

回答

1

如果你想從一個NSDictionary第N鍵,你總是可以做到這一點:

[[myDict allKeys] objectAtIndex:n]; 

不過,我懷疑你實際上並不希望出現這種情況,因爲鍵是不一定的順序你可能會認爲。也許你應該做的,而不是爲

NSArray* a = [NSArray arrayWithContentsOfFile:aPath]; 

只要你的plist是正確的結構,它應該給你的命令,你想