0

我今天早上更新到 XCode 8 并选择将我的 Swift 文件转换为 2.3 而不是 3。我已经解决了我所有的编译问题,除了下面的代码。只有 MFMailComposeResultSent 案例实际上做了重要的事情。XCode 说 MFMailComposeResultSent 和其他类似情况是未解析的标识符。最新的文档显示我应该使用 MFMailComposeResult.sent,并且自动建议功能提供了这种可能性,但它也拒绝编译。我将不胜感激有关如何使此编译器与 Swift 2.3 一起使用的信息。

谢谢。

func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError?) {
    switch result.rawValue {
    case MFMailComposeResultCancelled.rawValue:
        print("Mail canceled")
    case MFMailComposeResultSaved.rawValue:
        print("Mail saved")
    case MFMailComposeResultSent.rawValue:
        makeToast("Successfully sent email.", duration: 3)
        print("Mail sent")
    case MFMailComposeResultFailed.rawValue:
        print("Mail sent failure: \(error!.localizedDescription)")
    default:
        break
    }
    hideActivityIndicator()
    self.dismissViewControllerAnimated(true, completion: nil)
}
4

1 回答 1

1

rawValue无处不在是怎么回事?只需打开外壳即可。像这样:

switch result {
case .Cancelled: // something
case .Saved: // something
// .. and so on
于 2016-11-08T16:38:47.777 回答