iOS 内存释放

1.使用 RxSwift 引起的相互引用:

如button 点击事件中使用 self, tap 事件中使用self

//button 点击事件的相互引用
button.rx.tap.bind { [weak self] in
    guard let strongSelf = self else { return }
    strongSelf.view.backgroundColor = .white
}.disposed(by: disposeBag)
//tap 点击事件引起的相互引用
let tap = UITapGestureRecognizer()
tap.rx.event.subscribe(onNext: { [weak self] _ in
    guard let strongSelf = self else { return }
    ......
}).disposed(by: disposeBag)
self.addGestureRecognizer(tap)

2. 使用 NotificationCenter 的block 形式

NotificationCenter.default.addObserver(forName: LENotificationName.WXLogin, object: nil, queue: OperationQueue.main) { [weak self](noti) in
     self?.wechatDidLoginNotication(noti)
}

3. Block 动画不会引起相互引用

.....待更新

你可能感兴趣的:(iOS 内存释放)