Hopefully this is a simple issue? But I just cant seem to get my head around it.
I have a text field in my settingsViewController called emailText where I want to set the default email recipient.
@IBOutlet weak var emailText: UITextField!
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
let shoppingListViewController = segue.destinationViewController as! ShoppingListViewController
shoppingListViewController.emailString = ([emailText.text]!)
}
func textFieldShouldReturn(emailText: UITextField) -> Bool {
emailText.resignFirstResponder()
print ((emailText.text)!) //This prints the correct email address in the console.
return true;
}
My shoppingListViewController recieves this string by the following:
var emailString = ""
mailComposerVC.setToRecipients ([emailString])
My problem is that when I press my button to open the email I get 2016-05-26 14:25:14.617 MY APP Name [1397:520893] is not a valid email address in the console? And a blank To: field in the opened email.
Where am I going wrong?