title: How to initialise a string from NSData in Swift
body: <p>I have been trying to initialise a string from <code>NSData</code> in Swift.</p>
  
  <p>In the <a href="https://developer.apple.com/library/prerelease/ios/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/#//apple_ref/occ/instm/NSString/initWithData:encoding:" rel="noreferrer">NSString Cocoa Documentation</a> Apple is saying you have to use this:</p>
  
  <pre><code> init(data data: NSData!, encoding encoding: UInt)
  </code></pre>
  
  <p>However Apple did not include any example for usage or where to put the <code>init</code>.</p>
  
  <p>I am trying to convert the following code from Objective-C to Swift</p>
  
  <pre><code>NSString *string;
  string = [[NSString alloc] initWithData: data encoding: NSUTF8StringEncoding];
  </code></pre>
  
  <p>I have been trying a lot of possible syntaxes such as the following (of course it did not work):</p>
  
  <pre><code>var string:NSString!
  string = init(data: fooData,encoding: NSUTF8StringEncoding)
  </code></pre>