I have two UITableViewControllers and need to pass the value from the child view controller to the parent using a delegate. I know what delegates are and just wanted to see a simple to follow example.
Thank You
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Here’s a simple example:
Let’s say the child view controller has a
UISliderand we want to pass the value of the slider back to the parent via a delegate.In the child view controller’s header file, declare the delegate type and its methods:
ChildViewController.h
In the child view controller’s implementation, call the delegate methods as required.
ChildViewController.m
In the parent view controller’s header file, declare that it implements the
ChildViewControllerDelegateprotocol.RootViewController.h
In the parent view controller’s implementation, implement the delegate methods appropriately.
RootViewController.m