I am working in iOS and I have a custom view,
class MyView: UIView {
}
One of my ViewControllers
is using is,
class MyViewController: UIViewController {
viewDidLoad(){
let view = MyView() // ...
}
}
My custom view MyView
requires to observe a notification so I have added inside MyView's
init and removed in dealoc
block like,
class MyView: UIView {
init() {
addObserver(...)
}
dealloc{
removeObserver(...)
}
}
One of my colleagues commented that View should not handle observer rather associated ViewControllers
should handle them. Is there any problem of my design? What are the issues I might face in future if I follow my current design?
Aucun commentaire:
Enregistrer un commentaire