Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'id<MFMailComposeViewControllerDelegate>'from incompatible type 'ViewController *const_strong'

In my app I have a button that when pressed opens a email whit filled out "to" and "subject", but I get this warning on this line of code:

mc.mailComposeDelegate = self; 

The warning says:

Assigning to 'id<MFMailComposeViewControllerDelegate>'from incompatible type 'ViewController *const_strong'

What do I do? Please be very clear, I am not too skilled in xCode.

like image 903
Roy Pekny Avatar asked Feb 19 '23 02:02

Roy Pekny


1 Answers

This warning says that you haven't told the compiler that your class ViewController implements the MFMailComposeViewControllerDelegate protocol.

If you haven't done it, implement all the required methods from that protocol. In your case it's only one (– mailComposeController:didFinishWithResult:error:).

After that you have to tell the compiler that your class implements this protocol. You do this by adding <MFMailComposeViewControllerDelegate> to the @interface of ViewController. (The interface is in your header file, ViewController.h).

Your interface should now look similar to this:

@interface ViewController : UIViewController <MFMailComposeViewControllerDelegate>

@property ...

@end
like image 149
Matthias Bauch Avatar answered Apr 28 '23 03:04

Matthias Bauch