I’m working on iOS app using swift5.
There, some csv files are created on the app.
What I want to do is to name each csv file respectively, and share it to file app or SNS app using UIDocumentInteractionController. I coded like below, and no error occurred, but a folder named “document” was created and csv files which I didn’t expected were in it. I had no idea what was going on.
If you have any ideas about this problem, please share.
swift5
1 2// Get fileURL of Document directory. 3let documentDirectoryFileURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last! 4 5//csvStringArray contains String items which CSV files are made of. 6for i in 0..<csvStringArray.count{ 7 let fileName = String(i) + ".csv" 8 let csvData = csvStringArray[i] 9 10 let FilePath = documentDirectoryFileURL.appendingPathComponent(fileName) 11 do { 12 try csvData.write(to: FilePath, atomically: true, encoding: String.Encoding.utf8) 13 } catch let error as NSError { 14 print("failed to write: (error)") 15 } 16} 17 18documentInteraction = UIDocumentInteractionController() 19documentInteraction.url = documentDirectoryFileURL 20
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。