2012-01-20 7 views
0

私はこのNSDictionaryをテーブルビューにロードします。それは各辞書がそれのためのセルを持つためのセルを持っている必要があります。この場合、3セル。NSDictionaryをUITableViewにロードする

friendsDictionary: (
     { 
     name = Down; 
     age = 15; 
     birthday = Today; 
    }, 
     { 
     name = Charlie; 
     age = 12; 
     birthday = Today; 
    }, 
     { 
     name = Chris; 
     age = 18; 
     birthday = Today; 
    } 

編集:あなたは3 NSDictionariesでいっぱいにNSArrayが実際にそこにあるんだ何

NSString *path = [[NSBundle mainBundle] pathForResource:@"friendsList" ofType:@"plist"]; 
    NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path]; 
    NSDictionary *myDictionary = [dict objectForKey:@"friends"]; 
    self.friendsDictionary = myDictionary; 
    [aDictionary release]; 
+3

Happy Birthday Down、Charlie and Chris! – JustSid

答えて

2

。あなたのcellForRowAtIndexPathメソッドで

あなたはself.friendsDictionaryで(あなたの配列と仮定すると合成されたプロパティです)、あなたの配列を参照することができます。

したがって、あなたは[[cell textLabel] setText:[[self.friendsDictionary objectAtIndex:indexPath.row] objectForKey:@"name"]];

を行うことができ、あなたのUITableViewControllerサブクラスを設定する方法の詳細についてはTableViews Appleのサンプルコードを確認してください。 numberOfRowsInSection:を実装し、返信することを忘れないでください。[self.friendsDictionary count]

関連する問題