views:

30

answers:

1

Hi,

I'm populating a UITableView with NSDictionary and dictionaryWithContentsOfFile plist.

In the plist I have 3 rows, each row has an array.

I don't know what the id/index of the row will be.

Under:

// 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;
}

For cell.textLabel.text, how do I do something like [self.myList getKey]; where getKey will return the key/id of the row?

+1  A: 

If you want the Nth key from an NSDictionary, you could always do this:

[[myDict allKeys] objectAtIndex:n];

However, I suspect you don't actually want that since the keys are not necessarily in the order you might think. Perhaps what you should be doing instead is

NSArray* a = [NSArray arrayWithContentsOfFile:aPath];

So long as your plist is the right structure, it should give you the order you want

slf