Home » iOS programming » Swift 3.0.1: some changes

Swift 3.0.1: some changes

The new Swift 3 language has some changes, and the code must be updated. You can use automatic update, from the edit menu of Xcode, but in some cases code must be changed manually.
We’ll see only a subset of changes, so refer to the website www.swift.org which has published the official migration guide.

 Notes

 Previous
Version

Swift
3.0.1

increment operator i++ i+=1
for loops for var i = 0 ; i < 10 ;
i++ { print(i) }
for index in 0..<10
{ print(index) }
function parameters    they are constant
NSTimer
NSUserDefaults
NSBundle
NSFormatter
Timer
UserDefaults
Bundle
Formatter
let h = String(count:3,
repeatedValue:”0″)
// “000”
let h =
String(repeating:”02″, count:3)
// 020202
override func
tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:
NSIndexPath) -> UITableViewCell { }
override func tableView(_
tableView: UITableView, cellForRowAt indexPath: IndexPath) ->
UITableViewCell { }
tableView.dequeueReusableCellWithIdentifier
(“ProductCell”, forIndexPath: indexPath)
tableView.dequeueReusableCell
(withIdentifier: “ProductCell”, for: indexPath)
let red =
UIColor.redColor()
let red = UIColor.red()

 

Leave a Reply