Ich versuche eine meiner Anwendungen von Obj-C nach Swift zu migrieren und habe ein Problem mit der E-Mail-Verwaltung.
Ich suchte nach Stunden, aber ich habe nicht gefunden, wie dieses Problem zu lösen.
Grundsätzlich versuche ich die func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!)
Funktion zu migrieren.E-Mails senden - MFMailComposeResult
Das Problem ist, dass keine Optionen innerhalb des Schalters gültig sind.
func mailComposeController(controller: MFMailComposeViewController!, didFinishWithResult result: MFMailComposeResult, error: NSError!)
{
switch result.value
{
case CUnsignedInt(MFMailComposeResultCancelled):
var alert = UIAlertController(
title: NSLocalizedString("sendingStatus", tableName: "LocalizationFile", comment:"sendingStatus"),
message: NSLocalizedString("emailCancelledByUser", tableName: "LocalizationFile", comment:"emailCancelledByUser"),
preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(alert, animated: true, completion: nil)
case MFMailComposeResult(MFMailComposeResultFailed):
var alert = UIAlertController(
title: NSLocalizedString("sendingStatus", tableName: "LocalizationFile", comment:"sendingStatus"),
message: NSLocalizedString("emailSentFailed", tableName: "LocalizationFile", comment:"emailSentFailed"),
preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(alert, animated: true, completion: nil)
case MFMailComposeResultSaved:
var alert = UIAlertController(
title: NSLocalizedString("sendingStatus", tableName: "LocalizationFile", comment:"sendingStatus"),
message: NSLocalizedString("emailSaved", tableName: "LocalizationFile", comment:"emailSaved"),
preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(alert, animated: true, completion: nil)
default:
var alert = UIAlertController(
title: NSLocalizedString("sendingStatus", tableName: "LocalizationFile", comment:"sendingStatus"),
message: NSLocalizedString("emailNotSent", tableName: "LocalizationFile", comment:"emailNotSent"),
preferredStyle: UIAlertControllerStyle.Alert)
self.presentViewController(alert, animated: true, completion: nil)
}
}
OMG! Wirklich funktioniert gut ... Ich weiß nicht, wie ich das nicht gesehen habe. Vielen Dank!!!! –
Sie verwenden nun .rawValue anstelle von .value – jaminguy
@jaminguy Aktualisiert, danke –