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

Using protocols, NotificationCenter, or blocks to pass data between modal VC and its parent VC?

Is anyone well-seasoned with creating protocols in particular? I'm trying to pass a value (a search term) from the modal view controller to its parent view controller and have the parent refresh its view with that new data. Can't seem to wrap my head around protocols to get this working. I tried using blocks and NotificationCenter and that didn't quite work out either.

5 Answers

Here is a very short example I wrote, that hopefully will make things a little bit clearer :)

https://www.dropbox.com/s/77moisnpwguht9x/delegateExample.zip

Glad my last answer helped you. I was pressed for time when I wrote that, and didn't get a chance to add how you would go about doing it with blocks as well, so I updated the project ;)

https://www.dropbox.com/s/77moisnpwguht9x/delegateExample.zip

Best straight-forward example I've seen. Thanks bro. I love my Treehouse community<3

Dear Treehouse,

Please implement that awesome delete button just in case we have duplicate comments we want to get rid of.

Yours truly, Stephen W.

Awesome!