Coder Social home page Coder Social logo

Retain cycle about floatingpanel HOT 6 CLOSED

scenee avatar scenee commented on June 14, 2024
Retain cycle

from floatingpanel.

Comments (6)

andreaslindahl avatar andreaslindahl commented on June 14, 2024 1

If I remember correctly, the reason I got the retain cycle was that the FloatingPanelLayout and the parent VC were one and the same, i.e. I didn't create a separate class that implemented FloatingPanelLayout, but instead had my parent VC implement that protocol.

from floatingpanel.

andreaslindahl avatar andreaslindahl commented on June 14, 2024 1

Great! It's no big deal, once I figured out why it happened :)

from floatingpanel.

andreaslindahl avatar andreaslindahl commented on June 14, 2024

I think I figured out the issue. I'm returning my VC in the FloatingPanelControllerDelegate method floatingPanel(_ vc: FloatingPanelController, layoutFor newCollection: UITraitCollection). My VC is then retained by the FloatingPanel's layoutAdapter property, which probably creates the retain cycle.

So, the solution seems to be to NOT use the parent VC as FloatingPanelLayout... I did this, since I needed some properties and logic located in my VC in my FloatingPanelLayout instance, but that wasn't a good idea...

from floatingpanel.

scenee avatar scenee commented on June 14, 2024

Thank you for your helpful report! I appreciate it πŸ‘

I will try to fix the retain cycle issue.

from floatingpanel.

scenee avatar scenee commented on June 14, 2024

I might misunderstood your comments. On the master branch(head: cb54a2a), I think this issue could be solved by that FloatingPanelLayout instance has a weak reference to a parent vc.

from floatingpanel.

scenee avatar scenee commented on June 14, 2024

Oh, now I understand. Unfortunately, it's a defect in the library design ..😞
But the library will be able to notice the retain cycle on the case when a user add a panel to a parent view controller applying FloatingPanelLayout.

I'm going to add a code to print the warning when the case is detected.

from floatingpanel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.