Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Eilon Krauthammer
Eilon Krauthammer
4,768 Points

Passing data between to the parent view controller from a modal

So I've got a "reminders" app. I have a table view controller as my main view controller and an "add reminder" view controller which is modal. I want to pass the new reminder data to the mutable array of the the table view controller. I guess i need something like prepareForSegue but it's not really a segue... So how do i do that? Thanks

1 Answer

Thomas Nilsen
Thomas Nilsen
14,957 Points

If you have to viewControllers, A and B. B is presented modally and you want to pass information back to A. You could use blocks, notifications or delegates. In your case delegates would be the best choice.

Here is a tiny example to demonstrate:

https://www.dropbox.com/s/r5wnqhkm1m0qbio/Delegates.zip