In my main view controller, I have a button that calls a popover. Since the popover has it’s own view controller, its buttons call methods in the popover’s view controller. But how would I call a method from the main view controller?
I tried this. In the popover view controller I added a property in the .h
@class ViewController;
@interface PopoverContent : UIViewController <UITextFieldDelegate>
...
@property (strong, nonatomic) ViewController *parentView;
In my popover implementation I did this in viewDidLoad:
self.parentView = [[ViewController alloc] initWithNibName:nil bundle:nil];
In ViewController I have a method called generateHash so I tried
[parentView generateHash];
But I get the error:
No visible @interface for 'ViewController' declares selector 'generateHash'
Any idea what I’m doing wrong? Thanks
remove this line, don’t want to create a new instance of view controller
change this line
to this, so your parent view pointer is of the right class type
now inside parent views .m file
Then in PopoverView.m file, you can call methods of the parentView like so