Howdy,

I've got NSScrollView and NSLayoutConstraint which is defined as:

_scrollViewHeightConstraint = [TMIntegralLayoutConstraint 
constraintWithItem:self.scrollView
                                                                   
attribute:NSLayoutAttributeHeight
                                                                   
relatedBy:NSLayoutRelationEqual
                                                                      toItem:nil
                                                                   
attribute:NSLayoutAttributeNotAnAttribute
                                                                  multiplier:1.0
                                                                    
constant:sDefaultScrollViewHeight];
[self addConstraint:_scrollViewHeightConstraint];

… TMIntegralLayoutConstraint is subclass of NSLayoutConstraint with one 
overriden method only …

- (void)setConstant:(CGFloat)constant {
  [super setConstant:round( constant )];
}

This is because if I do not round constant NSWindow jumps up & down during 
animation, because animator sets constant to real number sometimes.

I'm animating height of scroll view with this simple line of code ...

[self.scrollViewHeightConstraint.animator setConstant:height];

… so far, so good and everything does work. But when I close & release window 
with this scroll view before the animation ends, app crashes …

*** -[NSScrollView 
nsli_lowerAttribute:intoExpression:withCoefficient:container:]: message sent to 
deallocated instance 0x109cd4da0

… NSScrollView is deallocated, so, I tried to do this …

NSView *view = self;
[NSAnimationContext beginGrouping];
[self.scrollViewHeightConstraint.animator setConstant:height];
[view setNeedsUpdateConstraints:YES];
[[NSAnimationContext currentContext] setCompletionHandler:^{
  [view layoutSubtreeIfNeeded];
}];
[NSAnimationContext endGrouping];

… to capture NSView until the animation ends. But I still do receive crashes.

Height constraint is added to the NSScrollView's superview. I tried to add it 
directly to the NSScrollView, but same problems.

Anynoe has an idea why this is happening? Should I stop animation somehow and 
remove this particular constraint before window is closed & released?

Thanks,
Robert

-- 
Robert @ Tapmates, Inc.

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to