我想在UITableView中顯示一個字典plist,我在這裏閱讀了許多問題和答案,但沒有運氣!它似乎細胞返回null!這裏是我的plist: 在閱讀Plist到UITableView時遇到問題
和我的代碼:
-(void)viewDidLoad {
NSString *path = [[NSBundle mainBundle] pathForResource:@"feed" ofType:@"plist"];
newsFeed = [NSArray arrayWithContentsOfFile:path];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return newsFeed.count;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return dictionary.allKeys.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
dictionary = [newsFeed objectAtIndex:indexPath.section];
cell.textLabel.text = [[newsFeed objectAtIndex:indexPath.row] valueForKey:@"title"];
return cell;
}
,結果是什麼:
什麼在字典中的價值? – Rajneesh071 2013-05-13 08:34:16
@ Rajneesh071 NSDictionary * dictionary; – 2013-05-13 08:34:35
我在問價值,你在哪裏設定價值 – Rajneesh071 2013-05-13 08:35:58