やるとしたら以下の感じになるでしょうか、参考にしてみてください。
swift
1
2@IBAction func didClickButton(_ sender: UIButton) {
3 let inputName = NameField.text
4 let inputMail = Mail.text
5 let inputDate = DateField.text
6 performSegue(withIdentifier: "toNext",sender: (inputName, inputMail, inputDate))
7}
8
9override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
10 if segue.identifier == "toNext",
11 let data: (nameText: String, mailText: String, birthDateText: String) = sender as? (String, String, String),
12 let nextVC = segue.destination as? NextViewController {
13 nextVC.NameText = data.nameText
14 nextVC.MailText = data.mailText
15 nextVC.BirthDateText = data.birthDateText
16 }
17}
swift
1@IBAction func didClickButton(_ sender: UIButton) {
2 guard let name = NameField.text, let mail = Mail.text, let birthDay = DateField.text else { return }
3 performSegue(withIdentifier: "toNext",sender: ProfileData(name: name, mail: mail, birthDay: birthDay))
4
5}
6
7override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
8 if segue.identifier == "toNext", let profileData = sender as? ProfileData {
9 let nextVC = segue.destination as! NextViewController
10 nextVC.NameText = profileData.name
11 nextVC.MailText = profileData.mail
12 nextVC.BirthDateText = profileData.birthDay
13 }
14}
swift
1struct ProfileData {
2 let name: String
3 let mail: String
4 let birthDay: String
5}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/11/17 10:43