Passing Data Between Controllers

The Birthday label on the Contacts screen is changed on the Date screen. When the user taps the Change button next to the birthday, the Date screen is opened with a Date Picker, where the user can choose the desired date. Tapping the Save button brings the user back to the Contact screen and changes the Birthday label to what was chosen in the Date Picker.

The standard way to pass data back from a View Controller is to use the delegate pattern. With this pattern, you will have a reference in the Date Controller back to whatever controller called it (allowing for the Date Controller to be used in many contexts), as well as one or more methods that the Date Controller knows exist in the calling controller. The delegate ...

Get Learning Mobile App Development: A Hands-on Guide to Building Apps with iOS and Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.