title: UITableViewAlertForLayoutOutsideViewHierarchy when UITableView doesn't have window iOS13
body: <p>I started to receive warning (below) on iOS13. I have noticed that this warning pops up because <code>UITableView</code>'s window is null (another tab is selected, pushed detailed view controller on table selection...).
  I am trying to update <code>UITableView</code> from <code>NSFetchedResultController</code> delegate. What is the correct way to do this on iO13 to keep table updated?</p>
  
  <p>Code below worked fine on previous releases.</p>
  
  <p>PS: Any kind of <code>beginUpdates</code> , <code>reloadRowsAtIndexPaths:withRowAnimation:</code> , <code>insertSections:withRowAnimation:</code> ,  <code>endUpdates</code> will cause this warning.</p>
  
  <p>PS: I tried reload table but if I navigate back I lose animation to deselect row (clear row selection).</p>
  
  <blockquote>
    <p>2019-09-27 09:40:42.849128+0200 xxx[63595:9762090] [TableView] Warning
    once only: UITableView was told to layout its visible cells and other
    contents without being in the view hierarchy (the table view or one of
    its superviews has not been added to a window). This may cause bugs by
    forcing views inside the table view to load and perform layout without
    accurate information (e.g. table view bounds, trait collection, layout
    margins, safe area insets, etc), and will also cause unnecessary
    performance overhead due to extra layout passes. Make a symbolic
    breakpoint at UITableViewAlertForLayoutOutsideViewHierarchy to catch
    this in the debugger and see what caused this to occur, so you can
    avoid this action altogether if possible, or defer it until the table
    view has been added to a window. Table view: ;
    layer = ; contentOffset: {0, -64};
    contentSize: {375, 3432}; adjustedContentInset: {64, 0, 0, 0};
    dataSource: ></p>
  </blockquote>
  
  <pre><code>// ------------  ------------  ------------  ------------  ------------  ------------
  #pragma mark - FetchedResultsController delegate
  
  - (void) controllerWillChangeContent:(NSFetchedResultsController *)controller {
  //    if (self.tableView.window) {
          [self.tableView beginUpdates];
  //    }
  }
  - (void) controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath {
  
      if (type == NSFetchedResultsChangeInsert &amp;&amp; newIndexPath != nil) {
          [self.tableView insertRowsAtIndexPaths:@[newIndexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
      }
  
      if (type == NSFetchedResultsChangeUpdate &amp;&amp; indexPath != nil) {
          [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
  //        id&lt;CellLoadable&gt; cell = [self.tableView cellForRowAtIndexPath:indexPath];
  //        [cell loadData:anObject];
      }
  
      if (type == NSFetchedResultsChangeMove &amp;&amp; indexPath != nil &amp;&amp; newIndexPath != nil) {
          // if cell is visible, update it
          id&lt;CellLoadable&gt; cell = [self.tableView cellForRowAtIndexPath:indexPath];
          [cell loadData:anObject];
          [self.tableView moveRowAtIndexPath:indexPath toIndexPath:newIndexPath];
      }
  }
  
  - (void) controller:(NSFetchedResultsController *)controller didChangeSection:(id&lt;NSFetchedResultsSectionInfo&gt;)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type {
  
      if (type == NSFetchedResultsChangeInsert) {
          [self.tableView insertSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
      }
      if (type == NSFetchedResultsChangeDelete) {
          [self.tableView deleteSections:[NSIndexSet indexSetWithIndex:sectionIndex] withRowAnimation:UITableViewRowAnimationFade];
      }
  }
  
  - (void) controllerDidChangeContent:(NSFetchedResultsController *)controller {
  //    if (self.tableView.window) {
          [self.tableView endUpdates];
  //    }
  }
  </code></pre>