When I run the code below on my simulator iPhone 8, then it works fine. When I run it on my iPhone 8 then is "file" always nil. What do I wrong??
func saveRobotData(nFile: String){
if let sURL = Bundle.main.url(forResource: "Foodgrease", withExtension: "csv"){
let data = nFile.data(using: String.Encoding.utf8)
guard let dataU = data else {
return
}
let file = FileHandle(forUpdatingAtPath: sURL.path)
print(sURL.path)
file?.seekToEndOfFile()
file?.write(dataU)
file?.closeFile()
}
}