Reputation: 2945
I was messing around in Xcode creating... something... when I needed to send a message to the MainViewController.m
from the FlipsideViewController.m
. Except, when I do, the ViewController I am sending the message from does not detect the method as existing, despite the fact that I put the method in MainViewController.h
. This is the method:
- (void)setAutosave:(BOOL)boolee {
_autosave = boolee;
}
I have imported the MainViewController into the FlipsideViewController, but as I call it ([NSMainViewController setAutosave:_autosave];
), it simply throws an error:
No known class method for selector 'setAutosave:'
I am doing this because FlipsideViewController
has a segmented control in it, which tells autosave
to be on or off, but it needs to send it's value to the other ViewController.
I really am stumped, help is appreciated.
Upvotes: 0
Views: 59
Reputation: 1618
MainViewController
is a class, you can't access instance method from a class.
You can add a property to FlipsideViewController, for example:
@property (weak, nonatomic) MainViewController *mainViewController;
Assign your MainViewController instance to mainViewController (how to assign depends on the relationship between your two view controllers), then you can invoke that method by [self.mainViewController setAutosave:_autosave];
.
Upvotes: 2