title: How to convert a base64String to String in Swift?
body: <p>I am receiving a base64String from webservice response in NSData, how to convert that base64String to String in swift?</p>
  
  <pre><code>    //Code
      var jsonResult = NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers, error: &amp;err) as! NSDictionary  // Response JSON from webservice
      var base64String : String = ""
      base64String = jsonResult["Base64String"] as! String  // Retrieve base64String as string from json response
      println("Base64String Alone: \(base64String)")
  
  // Code to decode that base64String
  let decodedData = NSData(base64EncodedString: base64String, options: NSDataBase64DecodingOptions(rawValue: 0))
                                      println("Decoded:  \(decodedData)")
                                      let decodedString = NSString(data: decodedData!, encoding: NSUTF8StringEncoding)
                                      println(decodedString) // Prints nil
  </code></pre>
  
  <p>Encode and decode of base64String works well for the files containing only text, if a file contains some table formats/images both encoding and decoding gives an invalid base64String. How to convert a file into base64String encode and decode whatever the contents of file ?
  File formats are doc, docx, pdf, txt</p>
  
  <p>Advance thanks for any help !</p>