从表示的标签添加 MFMailComposeViewController 中的收件人

Add recipient in MFMailComposeViewController from Label represented

我有一个允许用户通过 MFMailcomposeViewController 发送电子邮件的应用程序。

composeVC.setToRecipients(["email@gmail.com"]) 

在同一个视图控制器中,我有一个标签,代表从 Firestore 下载的人的电子邮件。我如何 setToRecipients 而不是 (["email@gmail.com"]) 到 (["mailRepresentedLabel@gmail.com"])

我希望它从邮件表示的标签中提取数据并将其自动添加到收件人,这样最终用户就不需要将电子邮件添加到 setToRecipient 它将自动从 mailRepresentedLabel 中提取

请帮忙

我当前的代码是这样的

               if !MFMailComposeViewController.canSendMail() {
                   print("Не удается отправить Имэйл")
                   return
               }
               let composeVC = MFMailComposeViewController()
               composeVC.mailComposeDelegate = self
                
               // Configure the fields of the interface.
        composeVC.setToRecipients(["\(String(describing: mailRepLabel))"])
               composeVC.setSubject("Register your client details with us")
               composeVC.setMessageBody("Dear agent please register your client with us by replying on that email in order for us to track the information that this client is came with you. if aftersometime the client would like to come without you we will always have the information that this client is came with you and we will send him back to you. Please reply with the following details: Client Name, Passport number Property Managers name.", isHTML: false)
                
               // Present the view controller modally.
               self.present(composeVC, animated: true, completion: nil)
               print("done")
           }
    
}

extension AgentViewController: MFMailComposeViewControllerDelegate {
    func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) {
        if let _ = error {
            controller.dismiss(animated: true)
        
        return
        
        }
        switch result {
        case .cancelled:
            print("Canceled")
        case.failed:
            print("Failed to send")
        case.saved:
            print("Saved")
        case.sent:
            print("Email Sent")
        }
        controller.dismiss(animated: true)
    }
}```

您可以使用 text 属性访问标签的文本内容。所以……是这样的吗?

mailComposer.setToRecipients([mailRepLabel.text])