简体   繁体   中英

I got error on Xcode7 for String

The error is "Cannot convert value of type'[AnyObject]' to expected argument type '[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. The Apple documentation gives this example

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

If Const.CONTACT_MAIL is a string then you can simply try this:

picker.setToRecipients([Const.CONTACT_MAIL])

It is because it expects an array

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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