title: How to decode received data with NSJSONSerialization as base64EncodedString and convert it to NSData in Swift
body: <p>We are able to encode an image data as base64EncodedString and send from an iOS device to an other one using NSJSONSerialization.</p>
  
  <p>Besides, We are able to receive the image data as base64EncodedString but we are unable
  to convert received base64EncodedString to an image at receiving  iOS device.</p>
  
  <p>We tested if we were received base64EncodedString using following code</p>
  
  <pre><code>    let gotInfo = notification.userInfo! as Dictionary
      let receivedData:NSData = gotInfo["data" ] as NSData
      let message = NSJSONSerialization.JSONObjectWithData(receivedData, options:NSJSONReadingOptions.AllowFragments, error: nil) as NSDictionary
      let receivedString = message
      let receivedD: AnyObject? = message.objectForKey("Field")
      println ("received2: \(receivedD )")
  </code></pre>
  
  <p>At that point "println" shows base64EncodedString of image but following code gives error "extra argument 'base64EncodedString' incall" and we are unable find why we are having this error.</p>
  
  <pre><code>    let decodedData = NSData(base64EncodedString: receivedD, options:NSDataBase64DecodingOptions())
  </code></pre>
  
  <p>Once we are able to convert received data to NSData we hope converting it to an image using </p>
  
  <pre><code>    let decodedimage = UIImage(data: decodedData!)
  </code></pre>