Iphone 将NSDictionary加载到UITableView中
我有一个要加载到表视图中的NSDictionary。每个字典应该有一个单元格,才能有一个单元格。在这种情况下有3个细胞Iphone 将NSDictionary加载到UITableView中,iphone,objective-c,nsdictionary,Iphone,Objective C,Nsdictionary,我有一个要加载到表视图中的NSDictionary。每个字典应该有一个单元格,才能有一个单元格。在这种情况下有3个细胞 friendsDictionary: ( { name = Down; age = 15; birthday = Today; }, { name = Charlie; age = 12; birthday = Today; },
friendsDictionary: (
{
name = Down;
age = 15;
birthday = Today;
},
{
name = Charlie;
age = 12;
birthday = Today;
},
{
name = Chris;
age = 18;
birthday = Today;
}
编辑:
实际上,这里有一个NSArray,里面有3本词典 在cellForRowAtIndexPath方法中,可以使用
self.friendsDictionary
引用数组(假设数组是合成属性)
因此,您可以执行[[cell textlab]setText:[[self.friendsDictionary objectAtIndex:indexath.row]objectForKey:@“name”]代码>
有关如何设置UITableViewController
子类的更多信息,请查看Apple的TableView示例代码。记住执行numberOfRowsInSection:并返回[self.friendsDictionary count]
祝查理和克里斯生日快乐!
NSString *path = [[NSBundle mainBundle] pathForResource:@"friendsList" ofType:@"plist"];
NSDictionary *dict = [[NSDictionary alloc] initWithContentsOfFile:path];
NSDictionary *myDictionary = [dict objectForKey:@"friends"];
self.friendsDictionary = myDictionary;
[aDictionary release];