我試圖以允許用戶在我的應用程序發送電子郵件,但我得到一個:它的聲明之前局部變量聲明迅速
使用局部變量「configureMailComposeViewController」的
這是代碼。
func item(_ item: Int, selectedAtContactIndex index: Int) {
var mailComposeViewController = configuredMailComposeViewController()
if MFMailComposeViewController.canSendMail() {
self.presentViewController(mailComposeViewController, animated: true, completion: nil)
} else {
}
}
func configuredMailComposeViewController() -> MFMailComposeViewController{
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self
mailComposerVC.setToRecipients([EmailAddressArray[index]])
mailComposerVC.setSubject("I need your help")
return mailComposerVC
}
無關的,爲什麼你叫'configuredMailComposeViewController'之前你叫'如果MFMailComposeViewController.canSendMail()'? – rmaddy
@john,你認爲這是什麼意思? 'MFMailComposeViewController()' – aircraft