I have a utility app. I've implemented this code on the flipside, which calls a Feedback view to send an email, like this tutorial. This works, but then when I click on the Send Feedback UIButton, my app immediately crashes with *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController sendMail]: unrecognized selector sent to instance 0x89c1960'.
I've checked these things:
I've declared the delegate properly and implemented it for the MailComposer.
My method, sendMail, is wired to the TouchUp Event for the button.
My method names agree:
- (IBAction)sendMail;
and
- (IBAction)sendMail
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mfViewController = [[MFMailComposeViewController alloc] init];
mfViewController.mailComposeDelegate = self;
[self presentModalViewController:mfViewController animated:YES];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Status:" message:@"Your phone is not currently configured to send mail." delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil];
[alert show];
}
}
The code doesn't event get to this method because I have a breakpoint set at the top of the method implementation but doesn't get called. Nor did a breakpoint at ViewDidLoad get activated.
Looking at this error closely:
reason: '-[UIViewController sendMail]: unrecognized selector sent to instance
it seems it is expecting a view controller named sendMail rather than a method. I read this post which seems very similar but I dont' see any other view controller names in the xib Identity drop down list. I think this is part of my problem but I'm not sure how to fix it.
Maybe I'm supposed to be presenting the MFMailComposer via a viewcontroller? If so, I'm not sure how to do that.
Any suggestions would be appreciated.