This question already has an answer here:
I am attempting to implement the MFMessageComposeViewControllerDelegate's required method
func messageComposeViewController(controller: MFMessageComposeViewController, didFinishWithResult result: MessageComposeResult) {
}
The issue is that I can't figure out how to compare the MessageComposeResult with its associated constants in swift(MessageComposeResultCancelled, MessageComposeResultSent, MessageComposeResultFailed). So far I have tried:
result == MessageComposeResultCancelled
and
result == MessageComposeResult(0)
both of which return the error "'MessageComposeResult' is not convertible to MirrorDisposition". Any insight on how I can resolve this error would be greatly appreciated.
Use
.MessageComposeResultCancelled
or the equivalents or, perhaps,result.value == MessageComposeResultCancelled
you are close but no cigar.
As a general rule of thumb, if the objC version is something like
MessageComposeResultCancelled
then the Swift equivalent is
MessageComposeResult.Cancelled
or in situations where the type
MessageComposeResult
is implied, you can just short hand it with.Cancelled
EDIT
I was completely wrong about that
result == MessageComposeResultCancelled
worked for me. I know you tried this already, so just double check that you have imported the MessageUI.framework into your project and make sure youimport MessageUI
.