Hello,
Earlier I tried to save .csv file using
func getDownloadsDirectory() -> NSString {
let paths = NSSearchPathForDirectoriesInDomains(.downloadsDirectory, .userDomainMask, true)
let documentsDirectory = paths[0]
return documentsDirectory as NSString
}
let filePath = BaseViewController.getDownloadssDirectory().appendingPathComponent("WalletTransactions.csv")
decodeData.write(toFile: filePath, atomically: true)
let str = String(decoding: decodeData, as: UTF8.self)
let vc = UIActivityViewController(activityItems: [str], applicationActivities: [])
vc.excludedActivityTypes = [
UIActivity.ActivityType.assignToContact,
UIActivity.ActivityType.saveToCameraRoll,
UIActivity.ActivityType.postToFlickr,
UIActivity.ActivityType.postToVimeo,
UIActivity.ActivityType.postToTencentWeibo,
UIActivity.ActivityType.postToTwitter,
UIActivity.ActivityType.postToFacebook,
UIActivity.ActivityType.openInIBooks
]
self.present(vc, animated: true, completion: nil)
But I want to download file in user's iphone, so that user can locate there .csv file in Files App of iPhone.
Using above code file was not saved in Files App of iPhone.
So, can you please look into it.
Also for my first question How can I change the extension of file.
Using:
let str = String(decoding: decodeData, as: UTF8.self)
let vc = UIActivityViewController(activityItems: [str], applicationActivities: [])
File is getting downloaded in .txt file.
Is there any way to remove this str before opening UiActivityController.