0

I am currently running an application with a MenuVC allowing users to pick their choice of four segues to present other VC's. When these four buttons/segues are triggered, a new VC is presented by method of showing. To deal with the problem of constantly increasing the memory usage because the VC's are being placed on top of each other, I have attempted to dismiss VC's in the segues as new VC's are being presented. The problem is, this logic does not work with my application, because the non Menu VC's can trigger segues to each other, thus creating problems with which VC is exactly shown after dismissal (Menu can show Records, and Records can show Options, causing issues with what VC is supposed to be on top).

I was wondering if there is a way to solve the issue of dismissing the VC's to free up memory without the implementation of a NavigationControllers as I have already progressed this far not using them.

For reference here is how I am presenting/dismissing each VC.

  @IBAction func moveToOptions(_ sender: Any) {
       self.dismiss(animated: true, completion: nil)
       self.performSegue(withIdentifier: "toOptionsSegue", sender: nil)
       AVAudioPlayer.playSpecAudio(audioPiece: "Click", volume: 0.7)
  }

Thank you.

Esperavo
  • 3
  • 3
  • Are you sure that this code dismisses then segues ? – Shehata Gamal Jul 01 '18 at 12:30
  • One way out is you can put these 4 view controllers in a tab bar, and button actions can display the appropriate tab. – naeemjawaid Jul 01 '18 at 12:32
  • @ – Sh_Khan Yes. If I look at memory usage, the movement from one VC to another does not utilize any memory. Though, even though I have this code in both directions, it is still using 1/2 of the memory that would have been used without the dismissals, every cycle. The logic is flawed in how it moves between VC's. That's where I am confused. Any idea why this could be? – Esperavo Jul 01 '18 at 12:37

0 Answers0