ios - How to override popToRootViewController to append a method? -


i subclassed uinavigationcontroller , through didshow delegate, called whenever new view controller pushed onto stack, update instance variable called previousviewcontroller (to able perform custom work).

the instance variable:

class sectionnavigationcontroller: uinavigationcontroller {      var previousviewcontroller: uiviewcontroller?     ... 

the delegate updated:

// nav controller delegate method (did show) func navigationcontroller(_ navigationcontroller: uinavigationcontroller, didshow viewcontroller: uiviewcontroller, animated: bool) {      if currentindex! > 0 {         previousviewcontroller = navigationcontroller.viewcontrollers[currentindex! - 1]     }  } 


consequence, however, whenever poptorootviewcontroller called, view controller underneath top view controller (previousviewcontroller) not deinitialized because of reference. how can override poptorootviewcontroller in such way append deinitialization of previousviewcontroller?

check this apple documentation

you resolve strong reference cycles defining of relationships between classes weak or unowned references instead of strong references.

you should declare var weak


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -