大家好,我需要在我的UICollectionViewCell
自定义课程中添加2个观察者。
我以这种方式实现了两个观察者
override init(frame: CGRect) {
super.init(frame: frame)
NotificationCenter.default.addobserver(self,selector: #selector(disablePreviousMinutes),name: Nsnotification.Name(rawValue: "NotificationIdentifier"),object: nil)
NotificationCenter.default.addobserver(self,selector: #selector(enableMinute),name: Nsnotification.Name(rawValue: "NotificationIdentifier2"),object: nil)
}
现在我想知道如何从我的UICollectionViewCell
类中移除观察者
我尝试调用override func willMove(toWindow newWindow: UIWindow?)
,但是通过这种方式,所有单元格都重复了所有插入的功能
从UICollectionViewCell
自定义类中删除观察者的最佳方法是什么?