Skip to content

Conversation

@szupzj18
Copy link

I used this amazing label for my project, it's perfect for my requirements (😄 thanks, bro.) , but I found that the timeLabel property might have retain cycle issue.

- (UILabel*)timeLabel {
    if (_timeLabel == nil) {
        _timeLabel = self;
    }
    return _timeLabel;
}

when no specific UILabel object was passed into this object, it will make the timeLabel pointer point to itself ( which is strong assignment), cause the retain cycle.
I tested on my device and that is the case.

I make a demo view controller and add this label as a subview of it.
when I quit the demo view controller. The object still exist on mem graph, which means mem leak (caused by the ivar: _timeLabel)
CleanShot 2023-05-15 at 23 08 53@2x

if I make it weak property, it will dealloc properly.
CleanShot 2023-05-15 at 23 10 54@2x

(I re-opened this pr, because I forgot to create a new branch lol.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant