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!

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

John Stephanites
John Stephanites
2,007 Points

Why do we need to do this in the first place.

We need to go from one page to the other and had already accomplished this by connecting the push. I don't get why we even have to do this. This is posted for the IOS tutorial Build a playlist browser app on the video about down casting. I have seen the other questions related to this but no one asked why we needed to do it in the first place.

4 Answers

Ravee Sundar
PLUS
Ravee Sundar
Courses Plus Student 1,975 Points

I think I understand your question now. You might have figured the purpose already by now. Just my 2 cents.

If the task is to change only the title of the label, then your approach is correct. But, that purpose of that session is to explain 3 things

1) How to pass information between 2 view controllers? Using [prepapreForSegue] method in MasterViewController.

2) How Segue holds the reference of the Detail View controller? Using segue.destinationViewController

3) How can the data in ViewController be modified in MasterController? After we get the reference of the ViewDetailConroller using segue, we can access the string(segueLabelText, in our case) property of the ViewDetailController.

If you observe, the value "Yay, you pressed the button" was actually set in the ViewMasterController. This value is passed to ViewDetailController and then set it to its label text property. Hence, we were able to pass value between from one controller to another.

Ravee Sundar
PLUS
Ravee Sundar
Courses Plus Student 1,975 Points

Can you please elaborate on your question "Why we have to do this". What are you doing apart from "push"?

John Stephanites
John Stephanites
2,007 Points

Sorry this was in the build a playlist IOS tutorial. When he added Yay you pressed the button in a seemingly difficult way programattically. I just thought why not double click and add the text right in the field. I thought maybe someone who had done the course could elaborate. I guess it's still kinda vague but I don't really know how to ask it any other way. Thanks for the reply and offer to help. I have moved on!

John Stephanites
John Stephanites
2,007 Points

Yes! Thanks Ravee. I am still a little confused over this and thus the horriblly styled question. I need to watch this series again because for some reason it is throwing me for a loop.