'FileManager IOS
I'm beginer with swift/Xcode. I've put a csv file in my simulator and also in my Iphone by airdrop in Document. I try to find it and i've always : FILE NOT AVAILABLE I've look at my Iphone the file is in Document Have you an idea to fix this problem? Is there a solution to find it anywhere in my Iphone or simulator unless I know the path? Thank you very much Best regards
***let path = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
let url = NSURL(fileURLWithPath: path)
if let pathComponent = url.appendingPathComponent("players.csv") {
let filePath = pathComponent.path
let fileManager = FileManager.default
if fileManager.fileExists(atPath: filePath) {
print("FILE AVAILABLE")
} else {
print("FILE NOT AVAILABLE")
}
} else {
print("FILE PATH NOT AVAILABLE")
}***
Solution 1:[1]
This should explain how to get the file and use it
https://www.swiftbysundell.com/articles/working-with-files-and-folders-in-swift/
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kingsley Mitchell |
