URBSegmentedControl icon indicating copy to clipboard operation
URBSegmentedControl copied to clipboard

cyclic references

Open rlaferla opened this issue 11 years ago • 1 comments

This code in URBSegmentedControl uses a block that refers to self. The problem is that self will be retained.

        [UIView animateWithDuration:0.4 animations:^{
            [self layoutSegments];
        }];

Instead, it should be something like:

        URBSegmentedControl * __weak weakSelf = self;
        [UIView animateWithDuration:0.4 animations:^{
            URBSegmentedControl * strongSelf = weakSelf;
            if (strongSelf) {
                [strongSelf layoutSegments];
            }
        }];

rlaferla avatar Feb 05 '15 17:02 rlaferla

Self will only be retained for the duration of the animation (In this case 0.4 seconds)

lordzsolt avatar Oct 26 '16 13:10 lordzsolt