I’ve got 2 view controllers, and the second view controller needs to change a label in the first view controller. One way this can be done is to make the first view controller a property so the second view controller can change it directly.
Only problem is that it’s spaghetti programming … how would one achieve this without falling for this trap?
One idea I had was to use delegate protocol to do this. Curious of opinions if any other ways.
For a simple application that does small tasks like changing a label, it isn’t highly frowned upon to create a property for the view controller. As your application grows, or if you need to do a lot of label changing, it may be best to set up delegates and protocols to change them for you. It’s mainly up to you: if you have a team or a large/growing app, you might want to consider using delegates and protocols because odds are you’ll be using them anyway for good MVC and KVO practices.