I have 2 classes geoViewController
and geoMainViewController
I have a method in the geoMainViewController
called getFoo
It looks like this:
- (NSString *)getFoo
{
NSString* foo = @"This is foo";
return foo;
}
I am trying to call getFoo
from the geoViewController
class.
I have #import "geoMainViewController.h"
in my geoViewController
m file.
I am trying instantiate the geoMainViewController
class and call the getFoo
method from the viewDidLoad in my geoViewController
class like this:
- (void)viewDidLoad
{
[super viewDidLoad];
geoMainViewController* mainVC = [[geoMainViewController alloc] init];
NSString* myFoo = [mainVC getFoo];
}
It seems to be instantiating the geoMainViewController
class fine but I am getting an error on NSString* myFoo = [mainVC getFoo];
The error is - no visible @interface for 'geoMainViewController' declares the selector 'getFoo'
I am sure I am missing a step because I am very new to Objective C. I am just not sure what I am doing wrong.
Any help on this would be great.
Thanks!
In your geoMainViewController.h
you should declare the selector to be visible:
-(NSString *)getFoo;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With