A one way segue?

Discussion in 'iOS Programming' started by whitedragon101, Mar 20, 2014.

  1. whitedragon101, Mar 20, 2014
    Last edited: Mar 20, 2014

    whitedragon101 macrumors 65816

    Sep 11, 2008
    I am moving from one view controller to another but I will never go back the other way. i.e I have:

    ViewControllerA //has a table view of records and a new record button
    ViewControllerB //ask questions and store answers in datamodel + a finish button that segues to ViewControllerC
    ViewControllerC //summary of answers and a button to go back to ViewControllerA

    So ViewControllerB segues to ViewControllerC and never goes back and I don't know how to dismiss it.

    I would like to do something like:

    - (IBAction)buttonPressed_finish_inViewControllerB:(id)sender
    //segue to next controller
    [self performSegueWithIdentifier:@"toViewControllerC" sender:self];
    //dismiss this controller (B) leaving the new controller (C) running
    [self dismissViewControllerAnimated:YES completion:nil];

    This seems to work. Is this ok to do?

    // Simply allowing view controllers to pile up 
    // and then  adding   .presentingViewController   as many 
    // times as is needed to get back to the one i want
    [self.presentingViewController.presentingViewController  dismissViewControllerAnimated:YES completion:nil];
    This way of doing it seems to mean if you go through 2 screens after the program loads and then you never use them again they just remain taking up memory for no reason.
  2. DannyBres macrumors 65816


    Oct 30, 2007
    When you go back to A does it contain a new record that was just created. If you click that can you then edit the record from C.

    If so I would implent c in a way that it can be used for editing and creating a new record.

    If once added they records cannot be edited, I would use something allong the lines of presentViewController:animated:completion: to present B, when dismissed ARC should destroy it and then just transistion to C from A.

    Hope this helps.

Share This Page