【发布时间】:2014-12-26 22:44:09
【问题描述】:
我知道如何创建一个文本文件,但它只能在我的应用程序中访问。
我需要添加什么才能使这是任何 iOS 文件浏览器都可以找到并打开的公共文档?
func saveInstructions(sender:AnyObject)
{
var savePath = fileDir()
var fileName = "filters.text"
var fileAtPath = savePath.path?.stringByAppendingPathComponent(fileName)
if(NSFileManager.defaultManager().fileExistsAtPath(fileAtPath!) == false)
{
NSFileManager.defaultManager().createFileAtPath(fileAtPath!, contents: nil, attributes: nil)
}
var fileHandle:NSFileHandle = NSFileHandle(forWritingAtPath: fileAtPath!)!
fileHandle.seekToEndOfFile()
fileHandle.writeData("text".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!)
}
【问题讨论】:
标签: ios xcode core-data swift file-io