1

I'm using 'AlamofireImage' pod and show images in collection View cell but client want to share Image I'm using this but not working :

var shareImages = [UIImage]()
    shareImages = [UIImage(named: "http://idea-factory.in/images/25-021.jpg")] as! [UIImage];
                    let activityViewController:UIActivityViewController = UIActivityViewController(activityItems:  shareImages, applicationActivities: nil)
                    let excludedTypes: [UIActivity.ActivityType] = [.postToVimeo, .postToTwitter, .assignToContact, .saveToCameraRoll]
                    activityViewController.excludedActivityTypes = excludedTypes
                    self.present(activityViewController, animated: true, completion: nil)

error comes : Thread 1: signal SIGABRT

2 Answers2

0

I'm not sure if this is helpful but I normally get that error if I either haven't linked up my view controllers properly or needed to force unwrap a value and haven't.

Toby Clark
  • 142
  • 12
0

You must use the image once it is received completely. One of the methods you can use is

let downloader = ImageDownloader()
let urlRequest = URLRequest(url: URL(string: "http://idea-factory.in/images/25-021.jpg")!)

    downloader.download(urlRequest) { response in
        print(response.request)
        print(response.response)
        debugPrint(response.result)

        if let image = response.result.value {
            //use your activity  controller here
        }
    }
Talha Ahmad Khan
  • 3,416
  • 5
  • 23
  • 38