Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView cells blank
    text
    copied!<p>I'm trying to recover after accidentally deleting my .m file. Does anyone see what I'm doing wrong that is causing my cells to all render blank?</p> <h2>.h</h2> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface FirstViewController : UITableViewController &lt;UITableViewDelegate, UITableViewDataSource&gt; { } @end </code></pre> <h2>.m</h2> <pre><code>#import "FirstViewController.h" #import "Shared.h" #import "Message.h" @implementation FirstViewController - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CellIdentifier"; // Dequeue or create a cell of the appropriate type. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } cell.textLabel.text = @"Foo"; return cell; } -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { NSLog([NSString stringWithFormat:@"Number of rows %i", [[Shared sharedInstance].messages count]]); //this comes back as 10 return [[Shared sharedInstance].messages count]; } </code></pre> <p>Update:</p> <p>I have it pinned down to a weird problem. In the following, i logs out as 10, but if I return i the rows show blank. If I return 10 as shown below, it works.</p> <pre><code>- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { #warning Incomplete method implementation. // Return the number of rows in the section. NSInteger i = [[Shared sharedInstance].messages count]; NSLog([NSString stringWithFormat:@"Number of rows %i", i]); return 10; } </code></pre> <p>Another update:</p> <p>Ok, I've gotten closer. It seems that although reloaddata is getting called when I walk through with debugger, it doesn't seem to be properly reloading. That's why the hard coded number worked if I used a hardcoded sample string for each row. The first time it gets loaded, the number of rows would be zero and since reloaddata isn't working, the next time it gets loaded it didn't update to 10 rows.<br> In case someone wonders if I'm connected to delegate and datasource.</p> <p><img src="https://i.stack.imgur.com/KwJzq.png" alt="screen capture"></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