example:
tapGestureRecognizer.rx.event.asDriver()
.drive(onNext: { [unowned self] _ in
self.view.endEditing(true)
})
.disposed(by: disposeBag)
since the disposeBag
is controlled by self, I would assume yes?
For many of us, it's best practice to always use weak combined with self inside closures to avoid retain cycles. However, this is only needed if self also retains the closure. By adding weak by default you probably end up working with optionals in a lot of cases while it's actually not needed.
Unowned references, like weak references, do not increase the retain count of the object being referred. However, in Swift, an unowned reference has the added benefit of not being an Optional. This makes them easier to manage rather than resorting to using optional binding.
Yes, if disposeBag is an member variable of self, that is safe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With