let strsize = 10_000_000
let tries = 100
var longstring:String = "a"
for i in 1...strsize {
longstring += "a"
}
for i in 1..<2 {
let basestring = NSData(base64EncodedString: longstring, options: .IgnoreUnknownCharacters)
print(basestring)
}
Writing a code in command prompt. What is the correct code to write for Swift 3 which I been getting use of unresolved identifier NSData
. Most of the tutorials on encoding string to base64 aren't working.
This is working for you on Linux or Mac? http://studyswift.blogspot.sg/2016/03/convert-nsdatauint8-to-base64-in-swift.html
Use this instead:
let longstring = "test123"
if let data = (longstring).data(using: String.Encoding.utf8) {
let base64 = data.base64EncodedString(options: Data.Base64EncodingOptions(rawValue: 0))
print(base64)// dGVzdDEyMw==\n
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With