[英]messageComposeViewController Error in Swift 2
The following code worked in Swift 1.2. 以下代码适用于Swift 1.2。 Now, I get an error: 现在,我收到一个错误:
"Value of type MessageComposeResult has no member 'value'" “MessageComposeResult类型的值没有成员'值'”
func messageComposeViewController(controller: MFMessageComposeViewController, didFinishWithResult result: MessageComposeResult) {
switch (result.value) {
case MessageComposeResultCancelled.value:
print("Message was cancelled")
self.dismissViewControllerAnimated(true, completion: nil)
case MessageComposeResultFailed.value:
print("Message failed")
self.dismissViewControllerAnimated(true, completion: nil)
case MessageComposeResultSent.value:
print("Message was sent")
self.dismissViewControllerAnimated(true, completion: nil)
default:
break;
}
}
What member of the result am I supposed to check in order to find the status of the message in Swift 2? 为了在Swift 2中找到消息的状态,我应该检查结果的哪个成员?
In Swift 2, value
does not exist in result
. 在斯威夫特2, value
不存在的result
。
Use result.rawValue
, instead. 请改用result.rawValue
。
use rawValue instead of value 使用rawValue而不是value
switch result.rawValue {
case MessageComposeResult.Cancelled.rawValue:
print("Message was cancelled")
controller.dismissViewControllerAnimated(true, completion: nil)
case MessageComposeResult.Failed.rawValue:
print("Message failed")
controller.dismissViewControllerAnimated(true, completion: nil)
case MessageComposeResult.Sent.rawValue:
print("Message was sent")
controller.dismissViewControllerAnimated(false, completion: nil)
default:
break
controller.dismissViewControllerAnimated(true, completion: nil)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.