Skip to content

Commit b0c39d2

Browse files
authored
Merge pull request #8 from TryFetch/kylef/sharesheet
Allow sharing downloaded files
2 parents d0f5a5e + 97787b7 commit b0c39d2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

Fetch/DownloadsTableViewController.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,18 @@ class DownloadsTableViewController: UITableViewController, DownloaderDelegate {
138138
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
139139
self.tableView.endUpdates()
140140
self.showNoResultsIfRequired()
141-
}
141+
},
142+
143+
UITableViewRowAction(style: .Normal, title: "Share") { [unowned self] action, indexPath in
144+
let path = Downloader.sharedInstance.downloadedFiles[indexPath.row]
145+
let documentsUrl = NSFileManager.defaultManager().URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first!
146+
let URL = documentsUrl.URLByAppendingPathComponent(path)!
147+
let viewController = UIActivityViewController(activityItems: [URL], applicationActivities: nil)
148+
let frame = self.tableView.rectForRowAtIndexPath(indexPath)
149+
viewController.popoverPresentationController?.sourceView = self.tableView
150+
viewController.popoverPresentationController?.sourceRect = frame
151+
self.presentViewController(viewController, animated: true, completion: nil)
152+
},
142153
]
143154
}
144155
}

0 commit comments

Comments
 (0)