Note that there are some explanatory texts on larger screens.

plurals
  1. POView-based NSTableView renders blank rows after inserting new rows with animation
    primarykey
    data
    text
    <p>I have a view-based <code>NSTableView</code> that I'm backing with an `NSMutableArray . Periodically I go out grab some data and want to insert new rows into the table at the top.</p> <p>When I do this without specifying an animation to <code>insertRowsAtIndexes:withAnimation:</code> it seems to work fine for hours on end. However, if I specify an animation, after about 7 or 8 inserts the table view starts to show blank rows where the inserts occurred. Scrolling down and then back up causes the new rows to render properly.</p> <p>The code that calls <code>insertRowsAtIndexes:withAnimation</code> is in a block, and not running on the main thread, but my inserts happen inside of dispatch_async on the main queue, so I dont' think it related to multithreading. </p> <p>Here is some code ... <code>self.contents</code> is my <code>NSMutableArray</code>.</p> <pre><code> dispatch_async(dispatch_get_main_queue(), ^{ [self.contentsTableView beginUpdates]; if(posts.count) { for(NSDictionary* dictionary in [posts reverseObjectEnumerator]) { FNPost* post = [[FNPost alloc] initWithDictionary:dictionary width:self.contentsTableView.frame.size.width]; post.delegate = self; [self.contents insertObject:post atIndex:0]; [self.contentsTableView insertRowsAtIndexes:[NSIndexSet indexSetWithIndex:0] withAnimation: NSTableViewAnimationSlideLeft]; } } [self.contentsTableView endUpdates]; }); </code></pre> <p>One thing I'm confused about is the part of the Apple <code>NSTableView</code> documentation for <code>insertRowsAtIndexes:withAnimation</code> that says:</p> <blockquote> <p>The numberOfRows in the table view will automatically be decreased by the count of indexes.</p> </blockquote> <p>I'm confused by what that statement implies about the relationship between the number of objects in my array (and hence the result of <code>numberOfRowsInTableView:</code>) and the number of rows the table view thinks it has. To my thinking the number of rows in the table view should equal my array count and I want to make sure that my understanding of this is not at the root of the problem but like I said, the table works fine if no animation is specified.</p> <p>Am I doing something obviously wrong here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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