In the below code I am trying to write to a file that I have in my project in xcode. But for some issue its not writing to it. I am getting no updated text in my file.(JSON file)
responseString = "Some Text"
if let path = Bundle.main.path(forResource: "mapsdatademo", ofType: "json") {
do{
try responseString.write(toFile: path, atomically: false, encoding: String.Encoding.utf8)
}catch {"Error writting data"}
}
I am able to read the file with:
if let path = Bundle.main.path(forResource: "mapsdatademo", ofType: "json") {
do {
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .alwaysMapped)}
Note: I am trying get get json data and write that into a file.