I have a modal view controller that attempts to set an flag (an NSNumber property) of the source view controller that called it in its prepareForSegue method. It fails to build with the error “No known instance method for selector ‘setGoToEditNewNote:'”. Here is the code:
Source View Controller .h:
@property (strong, nonatomic) NSNumber *goToEditNewNote;
Source View Controller .m:
@synthesize goToEditNewNote;
...
- (void)viewDidLoad
{
[super viewDidLoad];
// clear the flag
goToEditNewNote = [[NSNumber alloc] initWithBool:FALSE];
...
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if ([goToEditNewNote boolValue] == TRUE) {
goToEditNewNote = FALSE;
[self performSegueWithIdentifier: @"editNote" sender: self];
...
Modal View Controller .h:
Modal View Controller .m:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"done"])
{
[self done];
[[segue destinationViewController] setGoToEditNewNote:TRUE]; <<< get error here
}
}
I suspect the problem may have to do with goToEditNewNote not being retained when the modal view is loaded, but i don’t understand why not. I have set other properties such as the managedObjectContext in a similar way with success. Please be as specific as possible in your answer as I am a novice with ARC. Thanks – Tom
destinationViewControlleris of theidtype which doesn’t contain agoToEditNewNoteproperty. You probably want to castdestinationViewControllerto theSourceViewControllertype. This is usually a warning but it sounds like you’re treating all warnings as errors (I do this too).Your
-prepareForSegue:sender:should look something like this.