ios - Is there a better way for calling methods in a managing view controller from a managed view controller? -


in apps i've developed far, i've had uiviewcontroller in charge of presenting other uiviewcontrollers display transitions in ui. whenever i've had "managed" view controller call method in "managing" view controller, i've had ensure had reference managing controller inside of managed controller.

for example: if have uiviewcontroller called maincontroller in charge of managing other uiviewcontrollers in application's ui, , maincontroller creates 2 controllers presentation. called subcontroller1 , subcontroller2 respectively. if subcontroller1 finished , maincontroller needs display subcontroller2, i've set maincontroller reference variable inside of subcontroller1 communicate change maincontroller. means whenever maincontroller creates subcontroller1 has set subcontroller1's maincontroller reference variable self.

should worried memory usage method of communications? better off using notifications kind of behavior? major benefit i've found method i'm using makes incredibly easy share information between view controllers if necessary. thoughts appreciated.

handling changes, actions, or user interaction in other views essential use case of delegates. best practice have main controller delegate of first/second view controller, , events happen in child controllers, call methods on delegates, can take necessary action.

passing references way describe won't have noticeable memory impact, tightly couple code maincontroller, should avoided. should strive flexibility handle potential changes in future. happens if transition universal app , ipad ui has vastly different structure? delegates, need ensure contract between controllers intact, free change of underlying implementation details.

other options keeping values/state in sync between views are:


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -