Reputation: 211
I specifically am wondering how you could escape a newline in Swift, but generic escape characters would be great too.
In Python you can do this:
print("Dear grandma, \nHow are you?")
How can you do this in Swift?
Upvotes: 2
Views: 9248
Reputation: 98
Here is an example replacing a unicode character in a string with a comma (to give you a sense of using escaped unicodes).
address = address.stringByReplacingOccurrencesOfString("\u{0000200e}", withString: ",", options: nil, range: nil)
Upvotes: 1
Reputation: 4270
Newlines as \n
work in Swift string literals too.
Check out the docs: Special Unicode Characters in String Literals
Upvotes: 2