I have this NSDictionary that I want to load into a table view. It should have a cell for each dictionary to have a cell for it. So 3 cells in this case.
friendsDictionary: (
{
name = Down;
age = 15;
birthday = Today;
},
{
name = Charlie;
age = 12;
birthday = Today;
},
{
name = Chris;
age = 18;
birthday = Today;
}
Edit:
NSString *path = [[NSBundle mainBundle] pathForResource:@"friendsList" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
NSDictionary *myDictionary = [dict objectForKey:@"friends"];
self.friendsDictionary = myDictionary;
[aDictionary release];
What you’ve got there is actually an NSArray filled with 3 NSDictionaries.
In your cellForRowAtIndexPath method you can reference your array (Assuming your array is a synthesized property) with
self.friendsDictionary.Therefore you can do
[[cell textLabel] setText:[[self.friendsDictionary objectAtIndex:indexPath.row] objectForKey:@"name"]];Check Apple’s sample code for TableViews for more information on how to set up your
UITableViewControllersubclass. Remember to implement numberOfRowsInSection: and return[self.friendsDictionary count]