Leandroc
Leandroc

Reputation: 75

NSTable insertRowsAtIndexes animation

I'm calling the insertRowsAtIndexes and removeRowsAtIndexes to insert or delete from my NSTableView, both with animation (SlideDown for insert and SlideUp for remove), but how can I control so that I can only call insert or remove rows (do a new action) after the animation from the previous has finished?

because I am getting the error:

[NSMutableArray insertObjects:atIndexes:]: count of array (25) differs from count of index set (4)

If I do add and delete quickly. Or when I fast-click the insert. Any ideas?

Thanks.

Upvotes: 0

Views: 271

Answers (1)

Keith Knauber
Keith Knauber

Reputation: 802

see NSAnimationDelegate - (void)animationDidEnd:(NSAnimation *)animation

Also, try calling CALayer - (void)removeAllAnimations before any change.

Another problem with CALayer is that making massive changes can cause all memory to be gobbled up. Example: importing a massive file, cut/paste massive # of table entries. For this reason, I enclose massive changes in this block:

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue
    forKey:kCATransactionDisableActions];   
// ... perform massive change
[CATransaction commit];

Upvotes: 1

Related Questions