0

辞書を含む配列である plist があります。テーブル ビューに名前を出力しようとしていますが、名前が表示されません。私がこれまでに持っているのは次のコードです

    self = [super init];
if (self) {
    // Fetch from the app bundle... load the NSDictionary
    _qList = [NSArray arrayWithContentsOfURL:[[NSBundle mainBundle] URLForResource:@"test" withExtension:@"plist"]];

   _qNames=[_qList valueForKey:@"Name"];


}
return self;

そして、私のテーブルビューには

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];


    int index = [indexPath indexAtPosition:1];
NSString *key = [[self.test.qNames valueForKey:@"Name"] objectAtIndex:index];
NSString *value = [self.test.qNames objectForKey:key];
[[cell textLabel] setText:value];

    return cell;
}

私のplist構造は次のとおりです。

ルート (配列) -項目 0 (辞書) -名前 -クラス -年齢 -項目 1 (辞書) -名前 -クラス -年齢

等々..

置き方を工夫するしかない

 NSDictionary *name=[self.model.qList valueForKey:@"Name"];

テーブルビューに返す名前は?

4

1 に答える 1