title: Convert string to base64 in Swift 3
body: <pre><code>let strsize = 10_000_000
  let tries = 100
  var longstring:String = "a"
  
  for i in 1...strsize {
  longstring += "a"
  }
  
  for i in 1..&lt;2 {
  let basestring = NSData(base64EncodedString: longstring, options: .IgnoreUnknownCharacters)
  print(basestring)
  }
  </code></pre>
  
  <p>Writing a code in command prompt. What is the correct code to write for Swift 3 which I been getting <code>use of unresolved identifier NSData</code> . Most of the tutorials on encoding string to base64 aren't working.</p>
  
  <p>This is working for you on Linux or Mac?
  <a href="http://studyswift.blogspot.sg/2016/03/convert-nsdatauint8-to-base64-in-swift.html" rel="nofollow">http://studyswift.blogspot.sg/2016/03/convert-nsdatauint8-to-base64-in-swift.html</a></p>