0

Cocoa をNSMutableArray使用NSMutableDictionary'sしている場合にどのように使用できますか? NSTableView適切な解決策を教えてください。

4

1 に答える 1

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

ここで、array1 は、オブジェクトDataSourceを含むテーブル ビューのメインです。NSDictionary

お役に立てれば。

于 2013-01-22T07:25:39.180 に答える