Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix retain cycle #64

Merged
merged 3 commits into from
Mar 4, 2018
Merged

Fix retain cycle #64

merged 3 commits into from
Mar 4, 2018

Conversation

zintus
Copy link
Collaborator

@zintus zintus commented Mar 2, 2018

This PR introduces two changes:

Now view of Flex is hidden, because it's a weak variable, and users of Flex may brake this state. I think in practice it's rare to see Flex being cached far away from it's hosting view, so this shouldn't be a problem.

Now Flex don't hold strong reference to it's hosting view, as this introduce retain cycle.

@@ -31,7 +31,7 @@ public final class Flex {
/**
Flex items's UIView.
*/
public let view: UIView
private weak var view: UIView?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could just keep the setter private:

private (set) weak var view: UIView?

This way we could still access it as a weak reference.

Copy link
Member

@lucdion lucdion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@lucdion lucdion merged commit ab6919c into layoutBox:master Mar 4, 2018
@lucdion
Copy link
Member

lucdion commented Mar 5, 2018

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.

2 participants