[英]messageComposeViewController Error in Swift 2
以下代碼適用於Swift 1.2。 現在,我收到一個錯誤:
“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;
}
}
為了在Swift 2中找到消息的狀態,我應該檢查結果的哪個成員?
在斯威夫特2, value
不存在的result
。
請改用result.rawValue
。
使用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.