uiactivityviewcontroller share image swift

 let image: UIImage = arr.blogImage
 let imageToShare = [ image ]
 let activityViewController = UIActivityViewController(activityItems: imageToShare, applicationActivities: nil)
 activityViewController.popoverPresentationController?.sourceView = self.view // so that iPads won't crash 
 self.present(activityViewController, animated: true, completion: nil)