Created
October 12, 2015 09:35
-
-
Save dialektike/9b6e7a4d0149ba483001 to your computer and use it in GitHub Desktop.
from String to NSData, from NSData to String
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var swift_string = "lorem ipsum dolor sit amet" | |
// from String to NSData | |
let data = swift_string.dataUsingEncoding(NSUTF8StringEncoding) | |
print(data) | |
// from NSData to String | |
var out: String = String(data:data!, encoding:NSUTF8StringEncoding)! | |
print(out) // print "lorem ipsum dolor sit amet" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://qiita.com/kj1216/items/458f3b2ad8e5456eb399