I have to call MFMailComposeViewController 3 times in a loop, something like
for (int i=0; i<4; i++ {
[self presentMyMFMailComposeViewController];
}
the problem is that presenting a MFMailComposeViewController is an asynchronous task itself and as soon as the loop calls the controller the first time, it will not wait for the email to be sent and will call a second time and then a third.
How do I make it wait for the email to be sent?
You need to implement the MFMailComposeViewControllerDelegate, specifically the following method
This method is called when the mail view controller finishes, from here you can present a new mail view controller. Keep count of how many you have shown with an instance variable or the like.
Inside your presentMyMFMailComposeViewController method you set the delegate as follows.