简体   繁体   English

我在Xcode7上遇到String错误

[英]I got error on Xcode7 for String

The error is "Cannot convert value of type'[AnyObject]' to expected argument type '[String]?'". 错误是“无法将类型'[AnyObject]'的值转换为预期的参数类型'[String]?'”。 Does anyone know how to fix this? 有谁知道如何解决这一问题?

   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)
}

setToRecipients is expecting an array of strings. setToRecipients需要一个字符串数组。 The Apple documentation gives this example Apple文档提供了此示例

picker.setToRecipients(["address@example.com"])

If Const.CONTACT_MAIL is a string then you can simply try this: 如果Const.CONTACT_MAIL是字符串,则可以尝试以下操作:

picker.setToRecipients([Const.CONTACT_MAIL])

It is because it expects an array 这是因为它期望一个数组

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM