Closed VladislavHERZ closed 4 years ago
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?
Yes, when vc will be destroyed, need to destroy view(Alert), this process should be automatically. Alert don't should keep vc.
I'll think about it. in the meantime, you can call hide
in your view controller's disappearance method.
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?
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?".
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.
Select "case viewController(_: UIViewController)", and set duration == .forever. When dismiss or pop vc, we get retain cycle.