0

I am trying to send an email from within my iOS app using MFMailComposeViewController.

var mailhelp: MailComposerHelper? = nil

self.mailhelp = MailComposerHelper(fileName: self.currentObject.name as String, fileToSend: self.currentObject.lpath as String,sName: self.sName! as String)

self.mailhelp!.mailComposeDelegate = self
self.presentViewController(self.mailhelp!, animated: true, completion: nil)

The application crashes on this line:

self.mailhelp!.mailComposeDelegate = self

with:

fatal error: unexpectedly found nil while unwrapping an Optional value

Trying to print anything from within the mailhelp object, shows nil.

What's odd is that the app was already in use for some time now and this was tested and was working just fine just about 1 month or so ago. When I fired the app today, it crashed. Tried on all iOS devices, same thing. And I don't recall updating those devices recently or making any other change that might cause any issues.

Any thoughts? Also, has anyone encountered any similar issues (an app that start crashing out of the blue)?

daydr3am3r
  • 920
  • 4
  • 12
  • 31
  • Yes I am doing this, right before creating the mailhelper object and all are as expected. It was in fact the first thing I checked since the data for the app comes from a NodeJS/MongoDB server, – daydr3am3r Apr 26 '16 at 15:16
  • Maybe, check if you can send mail before ? MFMailComposeViewController .canSendMail() – ejanowski Apr 26 '16 at 15:17
  • 2
    Possible duplicate of [MFMailComposeViewController - iPad](http://stackoverflow.com/questions/4987703/mfmailcomposeviewcontroller-ipad) – picciano Apr 26 '16 at 15:40
  • Thanks. It seems this was caused by the fact there was no mail account set up. Thanks for the suggestion @ejanowski. – daydr3am3r Apr 27 '16 at 06:19

0 Answers0