Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:39:26+00:00 2026-06-13T16:39:26+00:00

I have two UIViewControllers with buttons triggering segue (modal) to each other. I wanted

  • 0

I have two UIViewControllers with buttons triggering segue (modal) to each other. I wanted to discover if that’s causing any memory leaks while jumping back and forth and I see that Living Object && allocated memory is going up, what eventually would leave to app crash. I don’t have any single line of code – working with pure UIViewControllers.
storyboard

profiler 1

profiler 2
project's settings

What I might be doing wrong?
Could have I set something wrong in project settings?
Am I reading profiler’s statictics badly?
Do I need to make any special release commands while working with segues?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:39:28+00:00Added an answer on June 13, 2026 at 4:39 pm

    You aren’t using the modal segues correctly. The way you have implemented it, you are creating a new instance of each view controller when you segue instead of returning to the instance you came from. That is why your memory usage continues to increase.

    Before iOS 6, the correct way to handle this was to:

    1) define a method such as viewController2Done in view controller 1
    2) in view controller 2, create a property called delegate of type id.
    3) in prepareToSegue for view controller 1, set delegate in view controller 2 to self
    4) in view controller 2, when it is time to return to view controller 1, call [delegate viewController2Done]
    5) in viewController2Done call [self dismissModalViewControllerAnimated:YES]

    This method still works in iOS 6, but there is also a new unwind segue that can be used instead. To use it, you would define a method in your view controller 1 like so:

    Objective-C:

    - (IBAction)unwindFromViewController2:(UIStoryboardSegue *)segue
    {
        NSLog(@"and we are back");
    }
    

    Swift:

    @IBAction func unwindFromViewController2(_ segue: UIStoryboardSegue) {
        print("and we are back")
    }
    

    Then you’d control drag from the button in view controller 2 to the orange exit icon in the bar above the view controller in the Storyboard. In the pop up, you’d select unwindFromViewController2 and voila, you’re done.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two UIViewControllers that are contained in a navigatoin view controller and both
I have two buttons that are not performing the IBAction that they are programmed
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two UIViewControllers, A and B, where A overrides the shouldAutorotateToInterfaceOrientation to return
I have two UIViewControllers in a storyboard (with a NavigationController ). I'm accessing the
I have two UIViewControllers which I sometimes need to show at the same time.
I'm writing a simple checklist app. I have two UIViewControllers. The first displays the
I have some code that shows two UIViewController in a delegate. RootViewController.m request =
I have an app that loads the camera and overlays buttons for fire, reload,
I have a main UIViewcontroller (vcMain) with two UIViewControllers subclassed from the main one.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.