Pdf document wont attach to iOS email

£可爱£侵袭症+ 提交于 2020-01-06 04:24:49

问题


I'm having problems getting this PDF document I created to attach to an email. So basically in my app I get the user to type in some text via a UITextfied and then take that text and put in into a PDF document. I then want the user to be able to send this PDF as an email attachment when clicking a button. Any thoughts on where I went wrong attaching this pdf as a attachment?

I got this code from Attach a PDF file to email - Swift and I just modified it but still no attachment. Also its coming up with the error

stringByAppendingPathComponent is unavailable: Use URLByAppendingPathCompenent on NSURL instead.

Had a look at this stringByAppendingPathComponent is unavailable and it doesnt make sense to me sorry.

//find the file and the path
let fileName: String = self.tfEssayTopicTitle.text!
let documentsPath = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.UserDomainMask, true)[0] as! String

let pdfFileName = documentsPath.stringByAppendingPathComponent(fileName + ".pdf")
let fileData = NSData(contentsOfFile: pdfFileName)
mailVC.addAttachmentData(fileData!, mimeType: "application/pdf", fileName: pdfFileName)

来源:https://stackoverflow.com/questions/36404234/pdf-document-wont-attach-to-ios-email

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!