gpt4 book ai didi

swift - MFMailComposeResult 常量不能在 Swift 2.3 中编译

转载 作者:行者123 更新时间:2023-11-28 16:04:24 26 4
gpt4 key购买 nike

我今天早上更新到 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)
}

最佳答案

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

switch result {
case .Cancelled: // something
case .Saved: // something
// .. and so on

关于swift - MFMailComposeResult 常量不能在 Swift 2.3 中编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40492079/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com