1

Below is shown navigation stack.

UIViewController -> UIContainerViewController -> UINavigationViewController -> UIPageViewController -> UIViewController

The parent view (First view controller) contains a button and child view (Last view controller) contains UITextField.

What I want to do is that when I press the button in parent view, the text from the child view text field should be stored in a NSString object in parent view.

What I tried is:

ChildViewController *CV = [self.childViewControllers lastObject]

ChildViewController *CV = [self.storyboard instantiateViewControllerWithIdentifier:@"ChildViewController"]

None of the above working.

Thanks in advance.

1 Answer 1

1

Use notifications, since the relationships between controllers are hard to handle, when you press the button post a buttonPressed notification and when the child VC received the notification post a needToStoreString notification and put the string in notification's userInfo and so the parent VC can know.

Sign up to request clarification or add additional context in comments.

1 Comment

Notifications can help and aren't a bad way to communicate between objects, but I wouldn't do it on everything. And at least you have delegates to communicate ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.