title: String to NSNumber in Swift
body: <p>I found a method to convert String to NSNumber, but the code is in Objective-C. I have tried converting it to Swift but it is not working.</p>
  <p>The code I am using:</p>
  <pre><code>NSNumberFormatter *f = [[NSNumberFormatter alloc] init];
  f.numberStyle = NSNumberFormatterDecimalStyle;
  NSNumber *myNumber = [f numberFromString:@&quot;42222222222&quot;];
  </code></pre>
  <p>and in Swift I am using it in this way:</p>
  <pre><code>var i = NSNumberFormatter.numberFromString(&quot;42&quot;)
  </code></pre>
  <p>But this code is not working. What am I doing wrong?</p>