Resolved How do I make a modal view controller's presenter do something when the MVC is done?

Discussion in 'iOS Programming' started by moonman239, Mar 3, 2014.

  1. moonman239, Mar 3, 2014
    Last edited: Mar 6, 2014

    moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I have two view controllers. I'll call them Amy and Bob, respectively. When Amy presents Bob, she uses a modal segue. Bob is supposed to be dismissed after a few seconds. When he is, Amy is supposed to do something.

    I'm thinking about making Amy Bob's parent view controller so that I can tell Bob to call the "dismissViewController" method of his parentViewController object.

    Edit: Thank you, dejo, for pointing me to the relevant Apple docs.
     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
  3. moonman239, Mar 3, 2014
    Last edited: Mar 3, 2014

    moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #3
    Not yet, but I did read the section entitled "Presenting View Controllers from Other View Controllers." In there, it mentions that each view controller has a presentingViewController property that is set to the view controller that is presenting it.

    Edit: After reading this page, I think I will use delegation.
     
  4. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #4
    P.S. It will probably help you get better recommendations if you were to elaborate on what you mean by "do something". Since what's being done might affect the way you want to handle this interaction.
     
  5. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #5
    Thanks for helping me. I ended up creating a delegate protocol, making Amy Bob's delegate, and having Bob call a method of Amy that is declared in the aforementioned delegate protocol.

    That is classified information. Besides, I think you would agree that having Amy do what I want done immediately after Bob finishes would be best.
     
  6. Duncan C macrumors 6502a

    Duncan C

    Joined:
    Jan 21, 2008
    Location:
    Northern Virginia
    #6
    Suggestion: Before posting a question, do at least a little research on the subject. At the VERY least, read the relevant sections of the Xcode docs.

    Otherwise it feels like you are expecting others on the forum to do you work for you, and that is maddening.
     

Share This Page