I want to send data to parentviewcontroller but the following code crashes. Give me the solution
Post *vc;
vc.abc =@"Comment Conttroller";
[self.parentViewController dismissModalViewControllerAnimated:YES];
Here, Post is the controller name from where I am calling the presentViewController:animated:completion
method.
vc
doesn't seem to be initialized.You can probably do this,
Since the view controller you want to affect is the
parentViewController
, you should be able to cast and set theabc
property.Take this in .h file in ParentViewController
Make below function in ParentViewController
Now In Post view controller do like this:
Now, In secondViewController
viewWillAppear
method write this.Please check spelling mistakes as I've hand written this. Hope this help.
If you are not using
UINavigationContoller
then you can do something like this.Put this in your parent controller in
viewDidLoad
Put following to your child class where
as soon as model view get dismiss yourNotificationHandler get executed and whatever you pass as an objet will get fetch in your parent class. Please ask if still need some clarification.