iphone - Having issue with reading Plist into UITableView -
i trying display dictionary plist uitableview , have read many question , answer here no luck ! seems cells return null ! here plist :
and codes :
-(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; }
and result nothing :
try in want display title try this
- (nsinteger)numberofsectionsintableview:(uitableview *)tableview { return 1; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return newsfeed.count; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { dictionary = [newsfeed objectatindex:indexpath.row]; cell.textlabel.text = [dictionary valueforkey:@"title"]; return cell; }
edit
, if want display record try this
- (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]; nsstring *key =[[dictionary allkeys] objectatindex:indexpath.row]; cell.textlabel.text = [dictionary valueforkey:key]; return cell; }
Comments
Post a Comment