Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems displaying plist in UITableView using storyboards? (Xcode)
    text
    copied!<p>I have done this on another project before and got it working then, but I cannot find out why this piece of my programming will not work. It displays the table without any of the plist data on it. Please take a look through my code to see if you can spot where I have made a mistake, thanks.</p> <pre><code>#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]; // Do any additional setup after loading the 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 any resources that can be recreated. } @end </code></pre> <p>My h. file is as follows:</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface MarketViewController : UIViewController &lt;UITableViewDataSource, UITableViewDelegate&gt; @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 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload