I compared MFMailComposeResult
documentation on both Xcode 5 and Xcode 6.
In Swift, MFMailComposeResult
is a struct
struct MFMailComposeResult {
init(_ value: CUnsignedInt) // available in iPhone 3.0
var value: CUnsignedInt
}
with MFMailComposeResultCancelled
as a constant of type MFMailComposeResult
:
var MFMailComposeResultCancelled: MFMailComposeResult { get }
while it’s an enum in Objective-C:
enum MFMailComposeResult {
MFMailComposeResultCancelled,
MFMailComposeResultSaved,
MFMailComposeResultSent,
MFMailComposeResultFailed
};
typedef enum MFMailComposeResult MFMailComposeResult; // available in iPhone 3.0
In order to make your code work, you will have to compare their values which are CUnsignedInt
.
So you will have to type the following code:
func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError) {
switch result.value {
case MFMailComposeResultCancelled.value:
println("Mail cancelled")
case MFMailComposeResultSaved.value:
println("Mail saved")
case MFMailComposeResultSent.value:
println("Mail sent")
case MFMailComposeResultFailed.value:
println("Mail sent failure: \(error.localizedDescription)")
default:
break
}
self.dismissViewControllerAnimated(false, completion: nil)
}