Problems displaying plist in UITableView using storyboards? (Xcode) -
i have done on project before , got working then, cannot find out why piece of programming not work. displays table without of plist data on it. please take through code see if can spot have made mistake, thanks.
#import "marketviewcontroller.h" #import "secondviewcontroller.h" #import "ecslidingviewcontroller.h" #import "menuviewcontroller.h" @interface marketviewcontroller () @end @implementation marketviewcontroller @synthesize shares, sharevalues, number, sharename; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { } return self; } - (void)viewdidload { self.navigationitem.title = @"stock market"; nsstring *sharesfile = [[nsbundle mainbundle] pathforresource:@"shares" oftype:@"plist"]; shares = [[nsdictionary alloc] initwithcontentsoffile: sharesfile]; sharevalues = [shares objectforkey:@"share values"]; sharename = [shares objectforkey:@"share names"]; [super viewdidload]; // additional setup after loading view. self.view.layer.shadowopacity = 0.75f; self.view.layer.shadowradius = 10.0f; self.view.layer.shadowcolor = [uicolor blackcolor].cgcolor; if (![self.slidingviewcontroller.underleftviewcontroller iskindofclass:[menuviewcontroller class]]) { self.slidingviewcontroller.underleftviewcontroller = [self.storyboard instantiateviewcontrollerwithidentifier:@"menu"]; } [self.view addgesturerecognizer:self.slidingviewcontroller.pangesture]; self.menubtn = [uibutton buttonwithtype:uibuttontypecustom]; _menubtn.frame = cgrectmake(8, 10, 34, 24); [_menubtn setbackgroundimage:[uiimage imagenamed:@"menubutton.png"] forstate:uicontrolstatenormal]; [_menubtn addtarget:self action:@selector(revealmenu:) forcontrolevents:uicontroleventtouchupinside]; [self.view addsubview:self.menubtn]; } //table view - (nsinteger) numberofsectionsintableview:(uitableview *)tableview { return 1; } -(nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return [shares count]; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath; { static nsstring *cellidentifier = @"cell"; uitableviewcell * cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (!cell) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstylesubtitle reuseidentifier:cellidentifier]; } nsstring *nameofshare = [sharename objectatindex:[indexpath row]]; nsstring *valueofshare = [sharevalues objectatindex:[indexpath row]]; cell.detailtextlabel.text = valueofshare; cell.textlabel.text = nameofshare; return cell; self.title = @"stock market"; } - (ibaction)revealmenu:(id)sender { [self.slidingviewcontroller anchortopviewto:ecright]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } @end
my h. file follows:
#import <uikit/uikit.h> @interface marketviewcontroller : uiviewcontroller <uitableviewdatasource, uitableviewdelegate> @property (strong, nonatomic) uibutton *menubtn; @property (nonatomic, readonly) nsdate *currentdate; @property (nonatomic, strong) nsdictionary *shares; @property (nonatomic, strong) nsarray *sharevalue; @property (nonatomic, strong) nsarray *number; @property (nonatomic, strong) nsarray *sharename; - (nsstring*)filepath; - (void)opendb; @end
Comments
Post a Comment