title: I have REAL misunderstanding with MFMailComposeViewController in Swift (iOS8) in Simulator
body: <p>I create a CSV file and try to send it by e-mail. Displays a window to send mail, but is not filled with the body of the email, and no attached file. Application hangs with this screen:</p>
  
  <p><a href="https://i.stack.imgur.com/ImeUH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ImeUH.png" alt="prntscr.com/4ikwwm"></a></p>
  
  <p>button "Cancel" does not work. After a few seconds in the console appears:</p>
  
  <pre><code>viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7f8409f29b50 {Message=Service Connection Interrupted}
  
  &lt;MFMailComposeRemoteViewController: 0x7f8409c89470&gt; timed out waiting for fence barrier from com.apple.MailCompositionService
  </code></pre>
  
  <p>There is my code:</p>
  
  <pre><code>func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int) {
      if buttonIndex == 0 {
          println("Export!")
  
          var csvString = NSMutableString()
          csvString.appendString("Date;Time;Systolic;Diastolic;Pulse")
  
          for tempValue in results {     //result define outside this function
  
              var tempDateTime = NSDate()
              tempDateTime = tempValue.datePress
              var dateFormatter = NSDateFormatter()
              dateFormatter.dateFormat = "dd-MM-yyyy"
              var tempDate = dateFormatter.stringFromDate(tempDateTime)
              dateFormatter.dateFormat = "HH:mm:ss"
              var tempTime = dateFormatter.stringFromDate(tempDateTime)
  
              csvString.appendString("\n\(tempDate);\(tempTime);\(tempValue.sisPress);\(tempValue.diaPress);\(tempValue.hbPress)")
          }
  
          let fileManager = (NSFileManager.defaultManager())
          let directorys : [String]? = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory,NSSearchPathDomainMask.AllDomainsMask, true) as? [String]
  
          if ((directorys) != nil) {
  
              let directories:[String] = directorys!;
              let dictionary = directories[0];
              let plistfile = "bpmonitor.csv"
              let plistpath = dictionary.stringByAppendingPathComponent(plistfile);
  
              println("\(plistpath)")
  
              csvString.writeToFile(plistpath, atomically: true, encoding: NSUTF8StringEncoding, error: nil)
  
              var testData: NSData = NSData(contentsOfFile: plistpath)
  
              var myMail: MFMailComposeViewController = MFMailComposeViewController()
  
              if(MFMailComposeViewController.canSendMail()){
  
                  myMail = MFMailComposeViewController()
                  myMail.mailComposeDelegate = self
  
                  // set the subject
                  myMail.setSubject("My report")
  
                  //Add some text to the message body
                  var sentfrom = "Mail sent from BPMonitor"
                  myMail.setMessageBody(sentfrom, isHTML: true)
  
                  myMail.addAttachmentData(testData, mimeType: "text/csv", fileName: "bpmonitor.csv")
  
                  //Display the view controller
                  self.presentViewController(myMail, animated: true, completion: nil)
              }
              else {
                  var alert = UIAlertController(title: "Alert", message: "Your device cannot send emails", preferredStyle: UIAlertControllerStyle.Alert)
                  alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
                  self.presentViewController(alert, animated: true, completion: nil)
  
  
              }
          }
          else {
              println("File system error!")
          }
      }
  }
  </code></pre>
  
  <p>Trying instead to send mail using <code>UIActivityViewController</code>:</p>
  
  <pre><code>let fileURL: NSURL = NSURL(fileURLWithPath: plistpath)
  let actViewController = UIActivityViewController(activityItems: [fileURL], applicationActivities: nil)
  self.presentViewController(actViewController, animated: true, completion: nil)
  </code></pre>
  
  <p>See approximately the same screen to send e-mail, which after a while returning to the previous screen. In the console, now another error:</p>
  
  <pre><code>viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7faab3296ad0 {Message=Service Connection Interrupted}
  Errors encountered while discovering extensions: Error Domain=PlugInKit Code=13 "query cancelled" UserInfo=0x7faab3005890 {NSLocalizedDescription=query cancelled}
  &lt;MFMailComposeRemoteViewController: 0x7faab3147dc0&gt; timed out waiting for fence barrier from com.apple.MailCompositionService
  </code></pre>
  
  <p>There was something about <code>PlugInKit</code>.</p>
  
  <p>Trying instead <code>UIActivityViewController</code> using <code>UIDocumentInteractionController</code>:</p>
  
  <pre><code>let docController = UIDocumentInteractionController(URL: fileURL)
  docController.delegate = self
  docController.presentPreviewAnimated(true)
  ...
  
  func documentInteractionControllerViewControllerForPreview(controller: UIDocumentInteractionController!) -&gt; UIViewController! {
      return self
  }
  </code></pre>
  
  <p>I see this screen with contents a CSV-file:</p>
  
  <p><a href="https://i.stack.imgur.com/BYEI0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BYEI0.png" alt="enter image description here"></a></p>
  
  <p>I press button export in top-right and see this screen:</p>
  
  <p><a href="https://i.stack.imgur.com/rLqfv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rLqfv.png" alt="enter image description here"></a></p>
  
  <p>where I choose MAIL and for several seconds I see:</p>
  
  <p><a href="https://i.stack.imgur.com/aAKWN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aAKWN.png" alt="enter image description here"></a></p>
  
  <p>Then returns to displaying the contents of the file! In the console the same messages as when using <code>UIActivityViewController</code>.</p>