Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
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.
 
Last edited:

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
Have you read the View Controller Programming Guide for iOS, particularly the section on "Coordinating Efforts Between View Controllers"?

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.
 
Last edited:

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
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.

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.

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.
 

Duncan C

macrumors 6502a
Jan 21, 2008
853
0
Northern Virginia
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.

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.