ios - Delegation pattern in Obj-C - Am I doing it wrong? -
so in app have following situation:
backendcommunicatingclass -> (owned by) -> modelclass -> (owned by) -> homescreenviewcontroller
- homescreenviewcontroller delegate modelclass.
- modelclass delegate backendcommunicatingclass.
also on when app launches first time, have this:
welcomeviewcontroller -> (owned by) -> homescreenviewcontroller
- homescreenviewcontroller delegate welcomeviewcontroller.
when user types username , password in welcomeviewcontroller, information needs way backendcommunicatingclass, , way welcomeviewcontroller display error if needed. right have implemented passing information each class in communication chain, until gets backendcommunicatingclass. result lot of duplication of protocol methods , feel i'm doing wrong.
what think?
well understand not clearest solution, without seing code, , purpose of program, suggest.
- implement key value observing (kvo) in end view controller, observing change in home view controller. end controller detect change in text field, trough dedicated variable in home view controller, fires operation has do.
- when end finish, sends nsnotification result of operation. home view controller have made listening such custom notification, react , display error message or other staff.
it may sounds complicated, kvo , notification easy implement, , there plenty of docs , tutorial on net.
Comments
Post a Comment