swift 中使用weak self
原创
©著作权归作者所有:来自51CTO博客作者mb63e0703549da8的原创作品,请联系作者获取转载授权,否则将追究法律责任
button.rx.tap.subscribe({ [weak self] _ in
self?.navigationController?.popViewController(animated: true)
}).disposed(by: disposeBag!)
button.rx.controlEvent(.touchUpInside).subscribe({ [weak self] _ in //必须要加[weak self],否则释放不掉,不会执行deinit
self?.navigationController?.popViewController(animated: true)
})
不管用哪种方式,如果调用self,必须要写[weak self],要不会释放不掉的