Read file in swift, iOS playground
up vote
12
down vote
favorite
Having searched through the many (many!) swift playground questions to even craft this code, I'm still struggling.
I've placed a text file in the Resources
folder of package contents, and it appears as an alias (link) in the running temp files generated by the playground (/var/folders/ ...
).
import UIKit
let bundle = NSBundle.mainBundle()
let myFilePath = bundle.pathForResource("dict1", ofType: "txt")
println(myFilePath) // <-- this is correct, there is a shortcut to the Resource file at this location
var error:NSError?
var content = String(contentsOfFile:myFilePath!, encoding:NSUTF8StringEncoding, error: &error)
println(content!) // <-- this is *NOT* the file contents [EDIT: see later note]
// Demonstrate there's no error
if let theError = error {
print("(theError.localizedDescription)")
} else {
print("No error")
}
The problem being, that content
is shown in the playground output as being Some "applengamenhownswiftntoken"
, rather than the file contents as expected.
It's finding the file, because if I change the filename, it errors. Any advice on getting the file contents?
Xcode 6.1
EDIT:
So, the actual problem was that I wasn't expecting the playground output (including, println
) to be escaped. That, combined with fatigue and other stupidities led me to believe there was a problem, when none existed.
Interestingly, not everything seems to be escaped in playground:
println("foonbar") // Outputs "foonbar", escaped
println("\n") // Outputs "n", unescaped
ios xcode swift swift-playground
add a comment |
up vote
12
down vote
favorite
Having searched through the many (many!) swift playground questions to even craft this code, I'm still struggling.
I've placed a text file in the Resources
folder of package contents, and it appears as an alias (link) in the running temp files generated by the playground (/var/folders/ ...
).
import UIKit
let bundle = NSBundle.mainBundle()
let myFilePath = bundle.pathForResource("dict1", ofType: "txt")
println(myFilePath) // <-- this is correct, there is a shortcut to the Resource file at this location
var error:NSError?
var content = String(contentsOfFile:myFilePath!, encoding:NSUTF8StringEncoding, error: &error)
println(content!) // <-- this is *NOT* the file contents [EDIT: see later note]
// Demonstrate there's no error
if let theError = error {
print("(theError.localizedDescription)")
} else {
print("No error")
}
The problem being, that content
is shown in the playground output as being Some "applengamenhownswiftntoken"
, rather than the file contents as expected.
It's finding the file, because if I change the filename, it errors. Any advice on getting the file contents?
Xcode 6.1
EDIT:
So, the actual problem was that I wasn't expecting the playground output (including, println
) to be escaped. That, combined with fatigue and other stupidities led me to believe there was a problem, when none existed.
Interestingly, not everything seems to be escaped in playground:
println("foonbar") // Outputs "foonbar", escaped
println("\n") // Outputs "n", unescaped
ios xcode swift swift-playground
1
That code works ok for me if I put adict1.txt
file in the appropriate place. What's in yourdict1.txt
file and how does it differ from what you see in yourcontent
variable?
– Mike S
Oct 23 '14 at 22:37
1
@MikeS, it's amazing how your simple question led me to the (obvious) answer. Yes, of coursecontent
matches the file. I should never code tired. What threw me off was the escaped'n'
, which made the content look like a path.
– alttag
Oct 24 '14 at 13:03
As I'm learning, playground output ofprintln
!= console output ofprintln
. More info on the console at this question.
– alttag
Oct 24 '14 at 16:07
add a comment |
up vote
12
down vote
favorite
up vote
12
down vote
favorite
Having searched through the many (many!) swift playground questions to even craft this code, I'm still struggling.
I've placed a text file in the Resources
folder of package contents, and it appears as an alias (link) in the running temp files generated by the playground (/var/folders/ ...
).
import UIKit
let bundle = NSBundle.mainBundle()
let myFilePath = bundle.pathForResource("dict1", ofType: "txt")
println(myFilePath) // <-- this is correct, there is a shortcut to the Resource file at this location
var error:NSError?
var content = String(contentsOfFile:myFilePath!, encoding:NSUTF8StringEncoding, error: &error)
println(content!) // <-- this is *NOT* the file contents [EDIT: see later note]
// Demonstrate there's no error
if let theError = error {
print("(theError.localizedDescription)")
} else {
print("No error")
}
The problem being, that content
is shown in the playground output as being Some "applengamenhownswiftntoken"
, rather than the file contents as expected.
It's finding the file, because if I change the filename, it errors. Any advice on getting the file contents?
Xcode 6.1
EDIT:
So, the actual problem was that I wasn't expecting the playground output (including, println
) to be escaped. That, combined with fatigue and other stupidities led me to believe there was a problem, when none existed.
Interestingly, not everything seems to be escaped in playground:
println("foonbar") // Outputs "foonbar", escaped
println("\n") // Outputs "n", unescaped
ios xcode swift swift-playground
Having searched through the many (many!) swift playground questions to even craft this code, I'm still struggling.
I've placed a text file in the Resources
folder of package contents, and it appears as an alias (link) in the running temp files generated by the playground (/var/folders/ ...
).
import UIKit
let bundle = NSBundle.mainBundle()
let myFilePath = bundle.pathForResource("dict1", ofType: "txt")
println(myFilePath) // <-- this is correct, there is a shortcut to the Resource file at this location
var error:NSError?
var content = String(contentsOfFile:myFilePath!, encoding:NSUTF8StringEncoding, error: &error)
println(content!) // <-- this is *NOT* the file contents [EDIT: see later note]
// Demonstrate there's no error
if let theError = error {
print("(theError.localizedDescription)")
} else {
print("No error")
}
The problem being, that content
is shown in the playground output as being Some "applengamenhownswiftntoken"
, rather than the file contents as expected.
It's finding the file, because if I change the filename, it errors. Any advice on getting the file contents?
Xcode 6.1
EDIT:
So, the actual problem was that I wasn't expecting the playground output (including, println
) to be escaped. That, combined with fatigue and other stupidities led me to believe there was a problem, when none existed.
Interestingly, not everything seems to be escaped in playground:
println("foonbar") // Outputs "foonbar", escaped
println("\n") // Outputs "n", unescaped
ios xcode swift swift-playground
ios xcode swift swift-playground
edited Oct 24 '14 at 16:04
asked Oct 23 '14 at 22:12
alttag
7391520
7391520
1
That code works ok for me if I put adict1.txt
file in the appropriate place. What's in yourdict1.txt
file and how does it differ from what you see in yourcontent
variable?
– Mike S
Oct 23 '14 at 22:37
1
@MikeS, it's amazing how your simple question led me to the (obvious) answer. Yes, of coursecontent
matches the file. I should never code tired. What threw me off was the escaped'n'
, which made the content look like a path.
– alttag
Oct 24 '14 at 13:03
As I'm learning, playground output ofprintln
!= console output ofprintln
. More info on the console at this question.
– alttag
Oct 24 '14 at 16:07
add a comment |
1
That code works ok for me if I put adict1.txt
file in the appropriate place. What's in yourdict1.txt
file and how does it differ from what you see in yourcontent
variable?
– Mike S
Oct 23 '14 at 22:37
1
@MikeS, it's amazing how your simple question led me to the (obvious) answer. Yes, of coursecontent
matches the file. I should never code tired. What threw me off was the escaped'n'
, which made the content look like a path.
– alttag
Oct 24 '14 at 13:03
As I'm learning, playground output ofprintln
!= console output ofprintln
. More info on the console at this question.
– alttag
Oct 24 '14 at 16:07
1
1
That code works ok for me if I put a
dict1.txt
file in the appropriate place. What's in your dict1.txt
file and how does it differ from what you see in your content
variable?– Mike S
Oct 23 '14 at 22:37
That code works ok for me if I put a
dict1.txt
file in the appropriate place. What's in your dict1.txt
file and how does it differ from what you see in your content
variable?– Mike S
Oct 23 '14 at 22:37
1
1
@MikeS, it's amazing how your simple question led me to the (obvious) answer. Yes, of course
content
matches the file. I should never code tired. What threw me off was the escaped 'n'
, which made the content look like a path.– alttag
Oct 24 '14 at 13:03
@MikeS, it's amazing how your simple question led me to the (obvious) answer. Yes, of course
content
matches the file. I should never code tired. What threw me off was the escaped 'n'
, which made the content look like a path.– alttag
Oct 24 '14 at 13:03
As I'm learning, playground output of
println
!= console output of println
. More info on the console at this question.– alttag
Oct 24 '14 at 16:07
As I'm learning, playground output of
println
!= console output of println
. More info on the console at this question.– alttag
Oct 24 '14 at 16:07
add a comment |
2 Answers
2
active
oldest
votes
up vote
11
down vote
You can try creating a class for opening and saving your files:
update: Xcode 10 • Swift 4.2
class File {
class func open(_ path: String, encoding: String.Encoding = .utf8) -> String? {
if FileManager.default.fileExists(atPath: path) {
do {
return try String(contentsOfFile: path, encoding: encoding)
} catch {
print(error)
return nil
}
}
return nil
}
class func save(_ path: String, _ content: String, encoding: String.Encoding = .utf8) -> Bool {
do {
try content.write(toFile: path, atomically: true, encoding: encoding)
return true
} catch {
print(error)
return false
}
}
}
usage: File.save
let stringToSave: String = "Your text"
let didSave = File.save("(NSHomeDirectory())/Desktop/file.txt", stringToSave)
if didSave { print("file saved") } else { print("error saving file") }
usage: File.open
if let loadedData = File.open("(NSHomeDirectory())/Desktop/file.txt") {
print(loadedData)
} else {
println("error reading file")
}
If you prefer working with URL
s (as I do and recommended by Apple):
Note that in Swift 4, the class URL
already exists.
class Url {
class func open(url: URL) -> String? {
do {
return try String(contentsOf: url, encoding: String.Encoding.utf8)
} catch {
print(error)
return nil
}
}
class func save(url: URL, fileContent: String) -> Bool {
do {
try fileContent.write(to: url, atomically: true, encoding: .utf8)
return true
} catch {
print(error)
return false
}
}
}
add a comment |
up vote
6
down vote
I have seen this problem with .txt files created from .rtf files using TextEdit.
I loaded a text.txt file in the resources folder of my playground using similar code to you. The file contents was "hello there" and was made by converting an .rtf file to .txt by changing the extension.
let path = NSBundle.mainBundle().pathForResource("text", ofType: "txt")//or rtf for an rtf file
var text = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)!
println(text)
The output was:
{rtf1ansiansicpg1252cocoartf1343cocoasubrtf140
{fonttblf0fswissfcharset0 Helvetica;}
{colortbl;red255green255blue255;}
margl1440margr1440vieww10800viewh8400viewkind0
pardtx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640pardirnatural
f0fs24 cf0 hello there}
So the "hello there" is embedded. This is the problem with all the layout information in a .rtf file.
I went back to TextEdit and created a true .txt file. After opening a file - Format|Make Plain Text
Now this same code gave the console output "hello there".
Hope this helps.
Useful information, but clearly this question does not suffer from the RTF issue. And as stupid as I feel about the mistake I made, I am certain I wouldn't have made this one!
– alttag
Oct 24 '14 at 13:04
Okay, glad you got your problem solved!
– Steve Rosenberg
Oct 24 '14 at 14:27
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
11
down vote
You can try creating a class for opening and saving your files:
update: Xcode 10 • Swift 4.2
class File {
class func open(_ path: String, encoding: String.Encoding = .utf8) -> String? {
if FileManager.default.fileExists(atPath: path) {
do {
return try String(contentsOfFile: path, encoding: encoding)
} catch {
print(error)
return nil
}
}
return nil
}
class func save(_ path: String, _ content: String, encoding: String.Encoding = .utf8) -> Bool {
do {
try content.write(toFile: path, atomically: true, encoding: encoding)
return true
} catch {
print(error)
return false
}
}
}
usage: File.save
let stringToSave: String = "Your text"
let didSave = File.save("(NSHomeDirectory())/Desktop/file.txt", stringToSave)
if didSave { print("file saved") } else { print("error saving file") }
usage: File.open
if let loadedData = File.open("(NSHomeDirectory())/Desktop/file.txt") {
print(loadedData)
} else {
println("error reading file")
}
If you prefer working with URL
s (as I do and recommended by Apple):
Note that in Swift 4, the class URL
already exists.
class Url {
class func open(url: URL) -> String? {
do {
return try String(contentsOf: url, encoding: String.Encoding.utf8)
} catch {
print(error)
return nil
}
}
class func save(url: URL, fileContent: String) -> Bool {
do {
try fileContent.write(to: url, atomically: true, encoding: .utf8)
return true
} catch {
print(error)
return false
}
}
}
add a comment |
up vote
11
down vote
You can try creating a class for opening and saving your files:
update: Xcode 10 • Swift 4.2
class File {
class func open(_ path: String, encoding: String.Encoding = .utf8) -> String? {
if FileManager.default.fileExists(atPath: path) {
do {
return try String(contentsOfFile: path, encoding: encoding)
} catch {
print(error)
return nil
}
}
return nil
}
class func save(_ path: String, _ content: String, encoding: String.Encoding = .utf8) -> Bool {
do {
try content.write(toFile: path, atomically: true, encoding: encoding)
return true
} catch {
print(error)
return false
}
}
}
usage: File.save
let stringToSave: String = "Your text"
let didSave = File.save("(NSHomeDirectory())/Desktop/file.txt", stringToSave)
if didSave { print("file saved") } else { print("error saving file") }
usage: File.open
if let loadedData = File.open("(NSHomeDirectory())/Desktop/file.txt") {
print(loadedData)
} else {
println("error reading file")
}
If you prefer working with URL
s (as I do and recommended by Apple):
Note that in Swift 4, the class URL
already exists.
class Url {
class func open(url: URL) -> String? {
do {
return try String(contentsOf: url, encoding: String.Encoding.utf8)
} catch {
print(error)
return nil
}
}
class func save(url: URL, fileContent: String) -> Bool {
do {
try fileContent.write(to: url, atomically: true, encoding: .utf8)
return true
} catch {
print(error)
return false
}
}
}
add a comment |
up vote
11
down vote
up vote
11
down vote
You can try creating a class for opening and saving your files:
update: Xcode 10 • Swift 4.2
class File {
class func open(_ path: String, encoding: String.Encoding = .utf8) -> String? {
if FileManager.default.fileExists(atPath: path) {
do {
return try String(contentsOfFile: path, encoding: encoding)
} catch {
print(error)
return nil
}
}
return nil
}
class func save(_ path: String, _ content: String, encoding: String.Encoding = .utf8) -> Bool {
do {
try content.write(toFile: path, atomically: true, encoding: encoding)
return true
} catch {
print(error)
return false
}
}
}
usage: File.save
let stringToSave: String = "Your text"
let didSave = File.save("(NSHomeDirectory())/Desktop/file.txt", stringToSave)
if didSave { print("file saved") } else { print("error saving file") }
usage: File.open
if let loadedData = File.open("(NSHomeDirectory())/Desktop/file.txt") {
print(loadedData)
} else {
println("error reading file")
}
If you prefer working with URL
s (as I do and recommended by Apple):
Note that in Swift 4, the class URL
already exists.
class Url {
class func open(url: URL) -> String? {
do {
return try String(contentsOf: url, encoding: String.Encoding.utf8)
} catch {
print(error)
return nil
}
}
class func save(url: URL, fileContent: String) -> Bool {
do {
try fileContent.write(to: url, atomically: true, encoding: .utf8)
return true
} catch {
print(error)
return false
}
}
}
You can try creating a class for opening and saving your files:
update: Xcode 10 • Swift 4.2
class File {
class func open(_ path: String, encoding: String.Encoding = .utf8) -> String? {
if FileManager.default.fileExists(atPath: path) {
do {
return try String(contentsOfFile: path, encoding: encoding)
} catch {
print(error)
return nil
}
}
return nil
}
class func save(_ path: String, _ content: String, encoding: String.Encoding = .utf8) -> Bool {
do {
try content.write(toFile: path, atomically: true, encoding: encoding)
return true
} catch {
print(error)
return false
}
}
}
usage: File.save
let stringToSave: String = "Your text"
let didSave = File.save("(NSHomeDirectory())/Desktop/file.txt", stringToSave)
if didSave { print("file saved") } else { print("error saving file") }
usage: File.open
if let loadedData = File.open("(NSHomeDirectory())/Desktop/file.txt") {
print(loadedData)
} else {
println("error reading file")
}
If you prefer working with URL
s (as I do and recommended by Apple):
Note that in Swift 4, the class URL
already exists.
class Url {
class func open(url: URL) -> String? {
do {
return try String(contentsOf: url, encoding: String.Encoding.utf8)
} catch {
print(error)
return nil
}
}
class func save(url: URL, fileContent: String) -> Bool {
do {
try fileContent.write(to: url, atomically: true, encoding: .utf8)
return true
} catch {
print(error)
return false
}
}
}
edited Nov 19 at 16:11
answered Oct 24 '14 at 3:18
Leo Dabus
129k30263339
129k30263339
add a comment |
add a comment |
up vote
6
down vote
I have seen this problem with .txt files created from .rtf files using TextEdit.
I loaded a text.txt file in the resources folder of my playground using similar code to you. The file contents was "hello there" and was made by converting an .rtf file to .txt by changing the extension.
let path = NSBundle.mainBundle().pathForResource("text", ofType: "txt")//or rtf for an rtf file
var text = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)!
println(text)
The output was:
{rtf1ansiansicpg1252cocoartf1343cocoasubrtf140
{fonttblf0fswissfcharset0 Helvetica;}
{colortbl;red255green255blue255;}
margl1440margr1440vieww10800viewh8400viewkind0
pardtx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640pardirnatural
f0fs24 cf0 hello there}
So the "hello there" is embedded. This is the problem with all the layout information in a .rtf file.
I went back to TextEdit and created a true .txt file. After opening a file - Format|Make Plain Text
Now this same code gave the console output "hello there".
Hope this helps.
Useful information, but clearly this question does not suffer from the RTF issue. And as stupid as I feel about the mistake I made, I am certain I wouldn't have made this one!
– alttag
Oct 24 '14 at 13:04
Okay, glad you got your problem solved!
– Steve Rosenberg
Oct 24 '14 at 14:27
add a comment |
up vote
6
down vote
I have seen this problem with .txt files created from .rtf files using TextEdit.
I loaded a text.txt file in the resources folder of my playground using similar code to you. The file contents was "hello there" and was made by converting an .rtf file to .txt by changing the extension.
let path = NSBundle.mainBundle().pathForResource("text", ofType: "txt")//or rtf for an rtf file
var text = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)!
println(text)
The output was:
{rtf1ansiansicpg1252cocoartf1343cocoasubrtf140
{fonttblf0fswissfcharset0 Helvetica;}
{colortbl;red255green255blue255;}
margl1440margr1440vieww10800viewh8400viewkind0
pardtx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640pardirnatural
f0fs24 cf0 hello there}
So the "hello there" is embedded. This is the problem with all the layout information in a .rtf file.
I went back to TextEdit and created a true .txt file. After opening a file - Format|Make Plain Text
Now this same code gave the console output "hello there".
Hope this helps.
Useful information, but clearly this question does not suffer from the RTF issue. And as stupid as I feel about the mistake I made, I am certain I wouldn't have made this one!
– alttag
Oct 24 '14 at 13:04
Okay, glad you got your problem solved!
– Steve Rosenberg
Oct 24 '14 at 14:27
add a comment |
up vote
6
down vote
up vote
6
down vote
I have seen this problem with .txt files created from .rtf files using TextEdit.
I loaded a text.txt file in the resources folder of my playground using similar code to you. The file contents was "hello there" and was made by converting an .rtf file to .txt by changing the extension.
let path = NSBundle.mainBundle().pathForResource("text", ofType: "txt")//or rtf for an rtf file
var text = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)!
println(text)
The output was:
{rtf1ansiansicpg1252cocoartf1343cocoasubrtf140
{fonttblf0fswissfcharset0 Helvetica;}
{colortbl;red255green255blue255;}
margl1440margr1440vieww10800viewh8400viewkind0
pardtx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640pardirnatural
f0fs24 cf0 hello there}
So the "hello there" is embedded. This is the problem with all the layout information in a .rtf file.
I went back to TextEdit and created a true .txt file. After opening a file - Format|Make Plain Text
Now this same code gave the console output "hello there".
Hope this helps.
I have seen this problem with .txt files created from .rtf files using TextEdit.
I loaded a text.txt file in the resources folder of my playground using similar code to you. The file contents was "hello there" and was made by converting an .rtf file to .txt by changing the extension.
let path = NSBundle.mainBundle().pathForResource("text", ofType: "txt")//or rtf for an rtf file
var text = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)!
println(text)
The output was:
{rtf1ansiansicpg1252cocoartf1343cocoasubrtf140
{fonttblf0fswissfcharset0 Helvetica;}
{colortbl;red255green255blue255;}
margl1440margr1440vieww10800viewh8400viewkind0
pardtx720tx1440tx2160tx2880tx3600tx4320tx5040tx5760tx6480tx7200tx7920tx8640pardirnatural
f0fs24 cf0 hello there}
So the "hello there" is embedded. This is the problem with all the layout information in a .rtf file.
I went back to TextEdit and created a true .txt file. After opening a file - Format|Make Plain Text
Now this same code gave the console output "hello there".
Hope this helps.
edited Oct 24 '14 at 1:37
answered Oct 24 '14 at 1:28
Steve Rosenberg
14.5k63948
14.5k63948
Useful information, but clearly this question does not suffer from the RTF issue. And as stupid as I feel about the mistake I made, I am certain I wouldn't have made this one!
– alttag
Oct 24 '14 at 13:04
Okay, glad you got your problem solved!
– Steve Rosenberg
Oct 24 '14 at 14:27
add a comment |
Useful information, but clearly this question does not suffer from the RTF issue. And as stupid as I feel about the mistake I made, I am certain I wouldn't have made this one!
– alttag
Oct 24 '14 at 13:04
Okay, glad you got your problem solved!
– Steve Rosenberg
Oct 24 '14 at 14:27
Useful information, but clearly this question does not suffer from the RTF issue. And as stupid as I feel about the mistake I made, I am certain I wouldn't have made this one!
– alttag
Oct 24 '14 at 13:04
Useful information, but clearly this question does not suffer from the RTF issue. And as stupid as I feel about the mistake I made, I am certain I wouldn't have made this one!
– alttag
Oct 24 '14 at 13:04
Okay, glad you got your problem solved!
– Steve Rosenberg
Oct 24 '14 at 14:27
Okay, glad you got your problem solved!
– Steve Rosenberg
Oct 24 '14 at 14:27
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f26538375%2fread-file-in-swift-ios-playground%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
That code works ok for me if I put a
dict1.txt
file in the appropriate place. What's in yourdict1.txt
file and how does it differ from what you see in yourcontent
variable?– Mike S
Oct 23 '14 at 22:37
1
@MikeS, it's amazing how your simple question led me to the (obvious) answer. Yes, of course
content
matches the file. I should never code tired. What threw me off was the escaped'n'
, which made the content look like a path.– alttag
Oct 24 '14 at 13:03
As I'm learning, playground output of
println
!= console output ofprintln
. More info on the console at this question.– alttag
Oct 24 '14 at 16:07