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

RetainCycle when select case "case viewController(_: UIViewController)" #359

Closed
VladislavHERZ opened this issue Oct 24, 2019 · 6 comments
Closed

Comments

@VladislavHERZ
Copy link

Select "case viewController(_: UIViewController)", and set duration == .forever. When dismiss or pop vc, we get retain cycle.

@wtmoose
Copy link
Member

wtmoose commented Oct 24, 2019

If you say .forever, it is up to you to call `hide at some point. Are you expecting it to auto-detect when you’re finished with the view and auto-hide?

@VladislavHERZ
Copy link
Author

VladislavHERZ commented Oct 24, 2019

Yes, when vc will be destroyed, need to destroy view(Alert), this process should be automatically. Alert don't should keep vc.

@wtmoose
Copy link
Member

wtmoose commented Oct 24, 2019

I'll think about it. in the meantime, you can call hide in your view controller's disappearance method.

@wtmoose
Copy link
Member

wtmoose commented Oct 24, 2019

Assuming I make this a weak reference, SwiftMessages still needs to update it's internal bookkeeping in order to present the next message in the queue via some kind of auto-dismiss based on the VC being deallocated. How would you propose that SwiftMessages detects when your view controller is deallocated?

@VladislavHERZ
Copy link
Author

Try this, but this code will be work only with vc.

struct WeakVCWrapper<Element:UIViewController> {
    weak var value:Element?

    init(_ value:Element) {
        self.value = value
    }
}

Or

struct WeakWrapper<Element:AnyObject> {
    weak var value:Element?

    init(_ value:Element) {
        self.value = value
    }
}

But you will need to cast to your type class use "as?".

@wtmoose
Copy link
Member

wtmoose commented Oct 27, 2019

The question was how would you propose detecting when the view controller is deallocated (not how to make a weak reference)? As I said, SwiftMessages needs to update its internal bookkeeping when the VC is deallocated in order to show the next message.

defagos added a commit to SRGSSR/playsrg-apple that referenced this issue Feb 17, 2020
SwiftMessage presenter still retains the view controller, see SwiftKickMobile/SwiftMessages#359.
defagos added a commit to SRGSSR/playsrg-apple that referenced this issue Feb 20, 2020
SwiftMessage presenter still retains the view controller, see SwiftKickMobile/SwiftMessages#359.
defagos added a commit to SRGSSR/playsrg-apple that referenced this issue Feb 25, 2020
SwiftMessage presenter still retains the view controller, see SwiftKickMobile/SwiftMessages#359.
defagos added a commit to SRGSSR/playsrg-apple that referenced this issue Feb 27, 2020
SwiftMessage presenter still retains the view controller, see SwiftKickMobile/SwiftMessages#359.
pyby pushed a commit to SRGSSR/playsrg-apple that referenced this issue Feb 27, 2020
SwiftMessage presenter still retains the view controller, see SwiftKickMobile/SwiftMessages#359.
defagos added a commit to SRGSSR/playsrg-apple that referenced this issue Mar 3, 2020
SwiftMessage presenter still retains the view controller, see SwiftKickMobile/SwiftMessages#359.
@wtmoose wtmoose closed this as completed Jul 9, 2020
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

No branches or pull requests

2 participants