0

Am using UIDocumentInteractionController to share file and to add openIn option to my app , but when i press send email i got an empty email , and i got the error from consol Attempting to load the view of a view controller while it is deallocating is not allowed and may result in undefined behavior ()

if i try to save the image "save image " i got this error Couldn't get file size for (null): (null)

this is my code

    var documentInteractionController:UIDocumentInteractionController?
    open func ShareButtonPressed(_ sender:UIButton){
    let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] + "/downloads"
    let name = String(format: "%@_%@", objDownloads[currentPageIndex].modificationDate!, objDownloads[currentPageIndex].fileName!)
    let url:URL = URL(fileURLWithPath: documentsPath.stringByAppendingPathComponent(name))
    let documentInteractionController = UIDocumentInteractionController(url:url)
    documentInteractionController.uti = objDownloads[currentPageIndex].fileName
    documentInteractionController.presentOptionsMenu(from: sender.frame, in: self.view, animated: true)
    documentInteractionController.delegate = self
}

and this my button code

    let shareBtn = UIButton()
    let shareIcon = UIImage(named: "share_icon")


    shareBtn.addTarget(self, action: #selector(SKPhotoBrowser.ShareButtonPressed(_:)), for: UIControlEvents.touchUpInside)
rmaddy
  • 314,917
  • 42
  • 532
  • 579
A.Munzer
  • 1,890
  • 1
  • 16
  • 27
  • check if URL is nil. – Avinay Kumar Oct 10 '16 at 12:51
  • i check the url , it correct and when i open it from "Go to Folder " i found it this example of the url that i got : file:///Users/abdallah/Library/Developer/CoreSimulator/Devices/D2C81451-A53B-4848-BF5A-37F6C92B3EDC/data/Containers/Data/Application/0CA7E9A1-DC42-42C8-84EA-70AFC92BBED1/Documents/downloads/130839398250000000_IMG_0038.JPG – A.Munzer Oct 10 '16 at 13:04

0 Answers0