| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

Swift对文件的简单读写操作

let file = "file.txt"   if let dirs : [String] = NSSearchPathForDirectoriesInDomains(NSSearchPathDirectory.DocumentDirectory, NSSearchPathDomainMask.AllDomainsMask, true) as? [String] {       let dir = dirs[0] //documents directory       let path = dir.stringByAppendingPathComponent(file);       let text = "some text" //writing      text.writeToFile(path, atomically: false, encoding: NSUTF8StringEncoding, error: nil); //reading       let text2 = String(contentsOfFile: path, encoding: NSUTF8StringEncoding, error: nil)   }