Convert string to integer


I have a string and want to parse its integer value (if any).


// String literal
let s = "1986"

// Get Integer value from string
var n = Int(s)

// It's an Optional Int -
// in case the conversion goes wrong


Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)