How writeToFile in a .playground?
modifying files in the main bundle doesn't appear to be possible, see earlier question. What you can do is to save to the sandboxed application folders, the URLs for which can be retrieved like this:
func applicationDirectory(directory:NSSearchPathDirectory) -> NSURL? {
var appDirectory:String?
var paths:[AnyObject] = NSSearchPathForDirectoriesInDomains(directory, NSSearchPathDomainMask.UserDomainMask, true);
if paths.count > 0 {
if let pathString = paths[0] as? String {
appDirectory = pathString
}
}
if let dD = appDirectory {
return NSURL(string:dD)
}
return nil
}
func applicationTemporaryDirectory() -> NSURL? {
if let tD = NSTemporaryDirectory() {
return NSURL(string:tD)
}
return nil
}
applicationTemporaryDirectory()
applicationDirectory(NSSearchPathDirectory.DocumentDirectory)
The urls will display in the righthand side of the playground, then simply copy and paste into the Finder -> Go -> Go to Folder dialogue box.
GitHub Repo: For a full working example see this GitHub repo.