Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is TableView not showing anything.
    text
    copied!<p>I have a class with a tableView. I get no build errors, but when I try to run the app, after I add a new item, nothing appears to happen. Here's the code:</p> <p>In .h</p> <pre><code>@interface entriesViewController : UIViewController &lt;UITableViewDelegate&gt; @property (weak, nonatomic) IBOutlet UITableView *TableView; -(IBAction)startEditing:(id)sender; -(IBAction)newItem:(id)sender; @end </code></pre> <p>In .m</p> <pre><code>#import "entriesViewController.h" #import "LEItemStore.h" #import "LEItem.h" @interface entriesViewController () @end @implementation entriesViewController @synthesize TableView; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization [TableView setDelegate:self]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. [TableView reloadData]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } -(IBAction)startEditing:(id)sender { if ([TableView isEditing]) { [TableView setEditing:NO animated:YES]; } else { [TableView setEditing:YES animated:YES]; } } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [[[LEItemStore sharedStore] allItems] count]; } -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"]; if (!cell) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"]; } LEItem *p = [[[LEItemStore sharedStore] allItems]objectAtIndex:[indexPath row]]; [[cell textLabel] setText:[p description]]; return cell; } -(IBAction)newItem:(id)sender { LEItem *newItem = [[LEItemStore sharedStore] createItem]; [TableView reloadData]; } -(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { if (editingStyle == UITableViewCellEditingStyleDelete) { LEItemStore *ps = [LEItemStore sharedStore]; NSArray *items = [ps allItems]; LEItem *p = [items objectAtIndex:[indexPath row]]; [ps removeItem:p]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } } -(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { [[LEItemStore sharedStore] moveItemAtIndex:[sourceIndexPath row] toIndex:[destinationIndexPath row]]; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { //NSArray *items = [[LEItemStore sharedStore] allItems]; //BNRItem *selectedItem = [items objectAtIndex:[indexPath row]]; } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [[self TableView]reloadData]; } </code></pre> <p>It would appear as if the TableView isn't reloading it's data. By the way, all connections have been made. Absolutely nothing appears. Just my Toolbar, the TableView does not change even after I added an item.</p>
 

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