0
現在、私はすぐにファイルから読み書きしていますが、書き込みはうまくいきませんが、書き込みは何もしていないようです。ここで私は読むために使用していますものです:Swift 2.0のファイルへの書き込みに関する問題
let path = NSBundle.mainBundle().pathForResource(filename, ofType: "txt")
let returnString = try? String(contentsOfFile: path!, encoding: NSUTF8StringEncoding)
を、ここで私が書くために使用しようとしていますものです:
let text = "hi mom"
let path = NSBundle.mainBundle().pathForResource(filename, ofType: "txt")
do{
try text.writeToFile(path, atomically: false, encoding: NSUTF8StringEncoding);
}
catch{
print("nope")
}
は、それがエラーを投げていないが、また、ファイル
を変更しません
参照が必要な場合はhttp://stackoverflow.com/questions/24097826/read-and-write-data-from-text-file/26557965#26557965 –