ios - How to refresh data from plist in Table View? -
so have situation. have table view, custom cells nib. i'm taking info plist properties of each cell. problem is, when alter view, view i'm changing array info should from, getting table view, , info won't refresh, , app gonna crash. every advice!!!
my .m file looks this:
#import "tableviewcontroller.h" #import "tableviewcell.h" static nsstring *celltableidentifier = @"tableviewcell"; @interface tableviewcontroller () @property (strong, nonatomic) iboutlet uibutton *citiesbutton; @property (copy, nonatomic) nsstring *path; @property (copy, nonatomic) nsdictionary *dict; @property (copy, nonatomic) nsarray *city; @property (copy, nonatomic) nsdictionary *rowdata; @end @implementation tableviewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view. rowvalue = @"brno"; self.path = [[nsbundle mainbundle] pathforresource:@"database2" oftype:@"plist"]; self.dict = [[nsdictionary alloc] initwithcontentsoffile:_path]; //main dictionary self.city = [_dict objectforkey:rowvalue]; [self.citiesbutton settitle:rowvalue forstate:uicontrolstatenormal]; uitableview *tableview = (id)[self.view viewwithtag:1]; { tableview.rowheight = 100; uinib *nib = [uinib nibwithnibname:@"miketableviewcell" bundle:nil]; [tableview registernib:nib forcellreuseidentifier:celltableidentifier]; uiedgeinsets contentinset = tableview.contentinset; contentinset.top = 20; [tableview setcontentinset:contentinset]; nslog(@"rowvalue %@", rowvalue); self.city = [_dict objectforkey:rowvalue]; } nslog(@"main view loaded successfuly"); } -(void)viewwillappear:(bool)animated { [self.citiesbutton settitle:rowvalue forstate:uicontrolstatenormal]; nslog(@"view appear"); } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { homecoming [self.city count]; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { homecoming 1; } - (float)tableview:(uitableview *)tableview heightforfooterinsection:(nsinteger)section{ //this space homecoming 50; } -(uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { tableviewcell *cell = [tableview dequeuereusablecellwithidentifier:celltableidentifier forindexpath:indexpath]; self.rowdata = _city[indexpath.section]; nslog(@"all keys dict: %@", [self.dict allkeys]); cell.timelabel.text = _rowdata[@"time"]; cell.pricelabel.text = _rowdata[@"price"]; cell.infolabel.text = _rowdata[@"info"]; cell.infolabel.transform = cgaffinetransformmakerotation(3.14/2); homecoming cell; } @end ios iphone objective-c cocoa-touch uitableview
No comments:
Post a Comment