Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView reloadData does not call delegates sometimes
    text
    copied!<p>I've spent hours trying to fix this</p> <p>What happen is this is I use NSFetchedResultController and then based on the content of the FetchController I update my table.</p> <p>In other word: standard practice.</p> <p>Quite often, I see that reloadData calls all the delegate. However NSFetchedResultController start of empty suddenly calling reloadData again after that won't load delegate.</p> <pre><code>-(void)ReloadorRedraw; { [BNUtilitiesQuick ListController].FetchController=[FetchClass standardFetchControler]; PO(self); //PO(self.tableViewA); listNewController * lc = [listNewController singleton]; PO(lc.FetchController); CLog(@"fetchController.fetchedObjects.count %d", lc.FetchController.fetchedObjects.count); PO(lc.FetchController.fetchedObjects); PO(self.tableViewA); PO(self.tableViewA.delegate); PO(self); PO(self); [self.tableViewA reloadData]; //No delegate is called here self.tableViewA.contentInset = UIEdgeInsetsZero;//I break here } </code></pre> <p>This is what I got the result sow that lc.FetchController is indeed populated. However, the table remain empty because none of those delegate that provides number of sections, numbers of rows in each section, are called at all.</p> <pre><code>2012-06-06 15:16:08.152 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(235)&gt; self: &lt;listNewController: 0x20abff00&gt; 2012-06-06 15:16:08.154 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(238)&gt; lc.FetchController: &lt;NSFetchedResultsController: 0xb2474fc0&gt; 2012-06-06 15:16:08.156 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(239)&gt; **fetchController.fetchedObjects.count 20** 2012-06-06 15:16:08.260 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(240)&gt; lc.FetchController.fetchedObjects: ( "&lt;Business: 0x7486afc0&gt; bla bla bla (too long)" ) 2012-06-06 15:16:08.268 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(241)&gt; self.tableViewA: &lt;UITableView: 0x2dbdbd10; frame = (0 -4; 320 352); clipsToBounds = YES; autoresize = W+H; autoresizesSubviews = NO; layer = &lt;CALayer: 0x2dbddfd0&gt;; contentOffset: {0, 0}&gt; 2012-06-06 15:16:08.271 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(242)&gt; self.tableViewA.delegate: &lt;listNewController: 0x20abff00&gt; 2012-06-06 15:16:08.273 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(243)&gt; self: &lt;listNewController: 0x20abff00&gt; 2012-06-06 15:16:08.275 BadgerNew[347:17303] &lt;0x20abff00 listNewController.m:(244)&gt; self: &lt;listNewController: 0x20abff00&gt; </code></pre> <p>I've heard cases where the issue is that tableViewA is not really pointing to the right tableViewA. So I set up breakpoint in:</p> <pre><code>-(void) setTableViewA:(UITableView *)tableViewArg { _tableViewA = tableViewArg; } -(UITableView *) tableViewA { return _tableViewA; } </code></pre> <p>I verify that setTableViewA is only called once, namely when the viewcontroller is loading and never change after that.</p> <p>I wonder if there is another thing I can do.</p> <p>Update: I set the background to blue in ReloadorRedraw, then I set it to red in some other function called when loading.</p> <p>ReloadorRedraw is called twice.</p> <p>First when the viewController is opened the first time. The second is after it's finish loading.</p> <p>The first time viewController is opened the table is indeed empty and background turn blue. Then it turns red. Then when downloading is finish it turns blue again.</p> <p>So the second time, tableViewA is the same tableViewA. The delegate is still indeed the controller. I checked that too.</p> <p>First time:</p> <pre><code>2012-06-06 20:54:43.500 BadgerNew[5822:17303] &lt;0x5cf0df00 listNewController.m:(263)&gt; lc.FetchController.fetchedObjects: ( ) 2012-06-06 20:54:43.502 BadgerNew[5822:17303] &lt;0x5cf0df00 listNewController.m:(264)&gt; self.tableViewA: &lt;UITableView: 0x62e15d10; frame = (0 -4; 320 352); clipsToBounds = YES; autoresize = W+H; autoresizesSubviews = NO; layer = &lt;CALayer: 0x62e17fd0&gt;; contentOffset: {0, 0}&gt; 2012-06-06 20:54:43.505 BadgerNew[5822:17303] &lt;0x5cf0df00 listNewController.m:(265)&gt; self.tableViewA.delegate: &lt;listNewController: 0x5cf0df00&gt; 2012-06-06 20:54:43.507 BadgerNew[5822:17303] &lt;0x5cf0df00 listNewController.m:(266)&gt; self: &lt;listNewController: 0x5cf0df00&gt; </code></pre> <p>Second time:</p> <pre><code>...lc.FetchController.fetchedObjects: ( tons of data here ) 2012-06-06 20:55:26.734 BadgerNew[5822:17303] &lt;0x5cf0df00 listNewController.m:(264)&gt; self.tableViewA: &lt;UITableView: 0x62e15d10; frame = (0 -4; 320 352); clipsToBounds = YES; autoresize = W+H; autoresizesSubviews = NO; layer = &lt;CALayer: 0x62e17fd0&gt;; contentOffset: {0, 0}&gt; 2012-06-06 20:55:26.737 BadgerNew[5822:17303] &lt;0x5cf0df00 listNewController.m:(265)&gt; self.tableViewA.delegate: &lt;listNewController: 0x5cf0df00&gt; 2012-06-06 20:55:26.739 BadgerNew[5822:17303] &lt;0x5cf0df00 listNewController.m:(266)&gt; self: &lt;listNewController: 0x5cf0df00&gt; </code></pre> <p>Update: removing tableViewA beginUpdates and endUpdates fix the issue. Basically make sure that fetch controller doesn't do anything.</p> <p>I think the code somehow messed up with inserting and exiting issues due to collapse all features or something.</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