2016-01-30 15 views
1

错误是“无法将类型'[AnyObject]的值转换为期望的参数类型'[String]?'”。有谁知道如何解决这一问题?我在Xcode7上得到了字符串错误

func send() { 
    let picker = MFMailComposeViewController() 
    picker.mailComposeDelegate = self 
    picker.setSubject(subject.text!) 
    //the code below is the reason I got error for 
    picker.setToRecipients(Const.CONTACT_MAIL) 
    picker.setMessageBody(body.text, isHTML: true) 
    presentViewController(picker, animated: true, completion: nil) 
} 
+0

什么是const的在你的代码? – user3182143

+0

这一行需要预期的类型Const.CONTACT_MAIL –

+0

那么我该怎么做? – hujihuji

回答

1

setToRecipients期待字符串数组。苹果文档给出了这样的例子

picker.setToRecipients(["[email protected]"]) 
+0

谢谢!成功了! – hujihuji

+0

如果你喜欢这个答案,你需要勾选它来鼓励人们帮助:-) – Russell

0

如果Const.CONTACT_MAIL是一个字符串,那么你可以简单地尝试这个办法:

picker.setToRecipients([Const.CONTACT_MAIL]) 

这是因为它需要一个数组

相关问题