SlideShare a Scribd company logo
1 of 23
Download to read offline
What’s new in Swift 3
22nd CocoaHeads SP @ Elo7 - Marcio Klepacz
@marciok
Agenda
• Introduction
• Where to find Swift 3
• A Swift more “Swifty”
• New Foundation Value Types
• Safety Increased
• Coolness with SPM
• Conclusion
Introduction
or what to expect from Swift 3
Swift 3
• Was also brought by proposals from the
community.
• Is focused on clarity, at the point of use.
• Brings more clarity when working with legacy
APIs
• Safer
Where to find Swift 3
Where to find Swift 3
• Xcode 8 (Beta)
• swift.org snapshots
Considerations
• You can only submit apps using Swift 3 when
Xcode GM is shipped ~end of 2016.
• Swift 3 changes everything. Xcode 8 comes
with a code migration tool (can migrate to 2.3).
However, I would still check the migrations made
by Xcode.
A Swift more “Swifty”
Swift more “Swifty”
• Not terse or Verbose code.
• Clarity is more important than brevity.
• Concise code is a consequence of using
contextual cues.
• What they mean (In my option) is: Let’s ditch
legacy ObjC API designs, and be more “Swifty”.
Before:
After:
NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, …)
NSTimer.scheduledTimer(timeInterval: 0.35, target: self, …)
UIFont.preferredFontForTextStyle(UIFontTextStyleSubheadline)
UIFont.preferredFont(forTextStyle: UIFontTextStyleSubheadline)
func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView?
func viewForZooming(in scrollView: UIScrollView) -> UIView?
Swift 2
Swift 3
Before:
After:
func findCocoaheads(in city: String) {
//...
}
findCocoaheads(in:"São Paulo")
func findCocoaheadsIn(city: String) {
//...
}
findCocoaheadsIn("São Paulo")
Swift 2
Swift 3
Before:
After:
UIColor.blueColor()
UIColor.blue() // or simply .blue() if the compile can infer
cocoaheads(insert: “São Paulo” atIndex: 0)
cocoaheads(insert: “São Paulo” at: 0)
NSUserDefaults.standardUserDefaults()
UserDefaults.standard() // NSUserDefaults was renamed to UserDefaults
Swift 2
Swift 3
Omitting needless words
New Foundation Value
Types
New Foundation value types
Example
let dateComponent = NSDateComponents()
dateComponent.year = 2016
let anotherComponent = dateComponent
anotherComponent.year = 2017 //`dateComponent` year was also changed to 2017
var dateComponent = DateComponents()
dateComponent.year = 2016 // It will warn you if `dateComponent` is a `let`
let anotherComponent = dateComponent
anotherComponent.year = 2017 //`dateComponent` is still 2016
Before:
Swift 2
After: Swift 3
Safety Increased
Safety Increased
Before:
After:
var cocoaheads = [String!]()
cocoaheads.append("São Paulo")
let sp = cocoaheads[0]
sp.dynamicType // ImplicitlyUnwrappedOptional<String>
Swift 2
Swift 3
var cocoaheads = [String!]()
cocoaheads.append("São Paulo")
let sp = cocoaheads[0]
sp.dynamicType // Optional<String>
let dangerousSp: String! = cocoaheads[0]
dangerousSp.dynamicType // ImplicitlyUnwrappedOptional<String>
No more `ImplicitlyUnwrappedOptional` propagation
Coolness with SPM
Coolness with SPM
• The ability to pass custom flags during linker
invocations. Also on C and Swift compilation.
• Export as dynamic library
==
• Easy to Interoperate with other languages
Coolness with SPM
• Examples:
• SwiftyRuby - Calling Ruby from Swift
• SwiftyJava - Calling Java from Swift
Conclusion
Conclusion
• Swift 3 changes everything (again). It will force
us get rid of our ObjC muscle muscle memory.
• Was also brought by the community. We can
always go on Github to complain, suggest and
change.
• There are many others news things that weren’t
mentioned at this presentation, so don’t forget to
check online for other things.
Thanks!
• Twitter: @marciok
• Github: /marciok
• References:
• https://www.raywenderlich.com/135655/whats-new-
swift-3
• https://www.bignerdranch.com/blog/wwdc-2016-
increased-safety-in-swift-3/
• https://developer.apple.com/videos/play/wwdc2016/402/

More Related Content

What's hot

What is storage class
What is storage classWhat is storage class
What is storage class
Isha Aggarwal
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
Aiman Hud
 

What's hot (20)

JavaScript Basics and Trends
JavaScript Basics and TrendsJavaScript Basics and Trends
JavaScript Basics and Trends
 
JavaScript introduction 1 ( Variables And Values )
JavaScript introduction 1 ( Variables And Values )JavaScript introduction 1 ( Variables And Values )
JavaScript introduction 1 ( Variables And Values )
 
Hardened JavaScript
Hardened JavaScriptHardened JavaScript
Hardened JavaScript
 
JavaScript 101 - Class 1
JavaScript 101 - Class 1JavaScript 101 - Class 1
JavaScript 101 - Class 1
 
Lambda Expressions in Java
Lambda Expressions in JavaLambda Expressions in Java
Lambda Expressions in Java
 
A Taste of Dotty
A Taste of DottyA Taste of Dotty
A Taste of Dotty
 
Core java concepts
Core java concepts Core java concepts
Core java concepts
 
What is storage class
What is storage classWhat is storage class
What is storage class
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Linq & lambda overview C#.net
Linq & lambda overview C#.netLinq & lambda overview C#.net
Linq & lambda overview C#.net
 
Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]Fundamental JavaScript [UTC, March 2014]
Fundamental JavaScript [UTC, March 2014]
 
AnyObject – 自分が見落としていた、基本の話
AnyObject – 自分が見落としていた、基本の話AnyObject – 自分が見落としていた、基本の話
AnyObject – 自分が見落としていた、基本の話
 
Kotlin
KotlinKotlin
Kotlin
 
Triggers in plsql
Triggers in plsqlTriggers in plsql
Triggers in plsql
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
eXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction TrainingeXo SEA - JavaScript Introduction Training
eXo SEA - JavaScript Introduction Training
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
What You Need to Know about Lambdas
What You Need to Know about LambdasWhat You Need to Know about Lambdas
What You Need to Know about Lambdas
 

Viewers also liked

ios_summit_2016_korhan
ios_summit_2016_korhanios_summit_2016_korhan
ios_summit_2016_korhan
Korhan Bircan
 

Viewers also liked (20)

Swift 3
Swift   3Swift   3
Swift 3
 
Swift, a nova linguagem de programação da Apple (CocoaHeads Sao Paulo)
Swift, a nova linguagem de programação da Apple (CocoaHeads Sao Paulo)Swift, a nova linguagem de programação da Apple (CocoaHeads Sao Paulo)
Swift, a nova linguagem de programação da Apple (CocoaHeads Sao Paulo)
 
A SOLUÇÃO DO TWITTER PARA DESENVOLVIMENTO DE MELHORES APPS
A SOLUÇÃO DO TWITTER PARA DESENVOLVIMENTO DE MELHORES APPSA SOLUÇÃO DO TWITTER PARA DESENVOLVIMENTO DE MELHORES APPS
A SOLUÇÃO DO TWITTER PARA DESENVOLVIMENTO DE MELHORES APPS
 
Ieeepro techno solutions ieee dotnet project - privacy-preserving multi-keyw...
Ieeepro techno solutions  ieee dotnet project - privacy-preserving multi-keyw...Ieeepro techno solutions  ieee dotnet project - privacy-preserving multi-keyw...
Ieeepro techno solutions ieee dotnet project - privacy-preserving multi-keyw...
 
iOS 10 & XCode 8, Swift 3.0 features and changes
iOS 10 & XCode 8, Swift 3.0 features and changesiOS 10 & XCode 8, Swift 3.0 features and changes
iOS 10 & XCode 8, Swift 3.0 features and changes
 
Swift 3 Programming for iOS : extension
Swift 3 Programming for iOS : extensionSwift 3 Programming for iOS : extension
Swift 3 Programming for iOS : extension
 
Swift 3 Programming for iOS : Enumeration
Swift 3 Programming for iOS : EnumerationSwift 3 Programming for iOS : Enumeration
Swift 3 Programming for iOS : Enumeration
 
Swift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming languageSwift Tutorial Part 2. The complete guide for Swift programming language
Swift Tutorial Part 2. The complete guide for Swift programming language
 
Korhan bircan
Korhan bircanKorhan bircan
Korhan bircan
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
ios_summit_2016_korhan
ios_summit_2016_korhanios_summit_2016_korhan
ios_summit_2016_korhan
 
Improving apps with iOS 10 notifications (do iOS 2016)
Improving apps with iOS 10 notifications (do iOS 2016)Improving apps with iOS 10 notifications (do iOS 2016)
Improving apps with iOS 10 notifications (do iOS 2016)
 
WWDC 2016
WWDC 2016WWDC 2016
WWDC 2016
 
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming LanguageSwift Tutorial Part 1. The Complete Guide For Swift Programming Language
Swift Tutorial Part 1. The Complete Guide For Swift Programming Language
 
Core Data with Swift 3.0
Core Data with Swift 3.0Core Data with Swift 3.0
Core Data with Swift 3.0
 
iOS 10
iOS 10iOS 10
iOS 10
 
WWDC 2016 Personal Recollection
WWDC 2016 Personal RecollectionWWDC 2016 Personal Recollection
WWDC 2016 Personal Recollection
 
I os swift 3.0 初體驗 &amp; 玩 facebook sdk
I os swift 3.0 初體驗 &amp; 玩 facebook sdkI os swift 3.0 初體驗 &amp; 玩 facebook sdk
I os swift 3.0 初體驗 &amp; 玩 facebook sdk
 
iOS 10 - What you need to know
iOS 10 - What you need to knowiOS 10 - What you need to know
iOS 10 - What you need to know
 
A swift introduction to Swift
A swift introduction to SwiftA swift introduction to Swift
A swift introduction to Swift
 

Similar to What's new in Swift 3

Similar to What's new in Swift 3 (20)

Swift 2.2 Design Patterns CocoaConf Austin 2016
Swift 2.2 Design Patterns CocoaConf Austin 2016Swift 2.2 Design Patterns CocoaConf Austin 2016
Swift 2.2 Design Patterns CocoaConf Austin 2016
 
A tour through Swift attributes
A tour through Swift attributesA tour through Swift attributes
A tour through Swift attributes
 
Tips and Tricks for Swift & Dot Swift 2016
Tips and Tricks for Swift & Dot Swift 2016Tips and Tricks for Swift & Dot Swift 2016
Tips and Tricks for Swift & Dot Swift 2016
 
Mobile, Open Source, and the Drive to the Cloud
Mobile, Open Source, and the Drive to the CloudMobile, Open Source, and the Drive to the Cloud
Mobile, Open Source, and the Drive to the Cloud
 
Mobile, Open Source, & the Drive to the Cloud
Mobile, Open Source, & the Drive to the CloudMobile, Open Source, & the Drive to the Cloud
Mobile, Open Source, & the Drive to the Cloud
 
Tips for migration from swift 2.2 to swift 3.0
Tips for migration from swift 2.2 to swift 3.0Tips for migration from swift 2.2 to swift 3.0
Tips for migration from swift 2.2 to swift 3.0
 
From CoreOS to Kubernetes and Concourse CI
From CoreOS to Kubernetes and Concourse CIFrom CoreOS to Kubernetes and Concourse CI
From CoreOS to Kubernetes and Concourse CI
 
Secure Coding For Java - Une introduction
Secure Coding For Java - Une introductionSecure Coding For Java - Une introduction
Secure Coding For Java - Une introduction
 
AWS Atlanta meetup Build Tools - Code Commit, Code Build, Code Deploy
AWS Atlanta meetup Build Tools - Code Commit, Code Build, Code DeployAWS Atlanta meetup Build Tools - Code Commit, Code Build, Code Deploy
AWS Atlanta meetup Build Tools - Code Commit, Code Build, Code Deploy
 
Swift on Raspberry Pi
Swift on Raspberry PiSwift on Raspberry Pi
Swift on Raspberry Pi
 
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
MongoDB World 2018: Tutorial - Got Dibs? Building a Real-Time Bidding App wit...
 
Discovering OpenBSD on AWS
Discovering OpenBSD on AWSDiscovering OpenBSD on AWS
Discovering OpenBSD on AWS
 
Fastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS Apps
 
Learn Electron for Web Developers
Learn Electron for Web DevelopersLearn Electron for Web Developers
Learn Electron for Web Developers
 
CI/CD on AWS
CI/CD on AWSCI/CD on AWS
CI/CD on AWS
 
Swift 5.2 what are the new things that you need to know about
Swift 5.2   what are the new things that you need to know aboutSwift 5.2   what are the new things that you need to know about
Swift 5.2 what are the new things that you need to know about
 
20171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v0120171122 aws usergrp_coretech-spn-cicd-aws-v01
20171122 aws usergrp_coretech-spn-cicd-aws-v01
 
DevOps Tooling - Pop-up Loft TLV 2017
DevOps Tooling - Pop-up Loft TLV 2017DevOps Tooling - Pop-up Loft TLV 2017
DevOps Tooling - Pop-up Loft TLV 2017
 
Zure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training dayZure Azure PaaS Zero to Hero - DevOps training day
Zure Azure PaaS Zero to Hero - DevOps training day
 
Scalable full-stack development at the edge - Pascal Wolkotte - Codemotion Am...
Scalable full-stack development at the edge - Pascal Wolkotte - Codemotion Am...Scalable full-stack development at the edge - Pascal Wolkotte - Codemotion Am...
Scalable full-stack development at the edge - Pascal Wolkotte - Codemotion Am...
 

Recently uploaded

CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Recently uploaded (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 

What's new in Swift 3

  • 1. What’s new in Swift 3 22nd CocoaHeads SP @ Elo7 - Marcio Klepacz @marciok
  • 2. Agenda • Introduction • Where to find Swift 3 • A Swift more “Swifty” • New Foundation Value Types • Safety Increased • Coolness with SPM • Conclusion
  • 3. Introduction or what to expect from Swift 3
  • 4. Swift 3 • Was also brought by proposals from the community. • Is focused on clarity, at the point of use. • Brings more clarity when working with legacy APIs • Safer
  • 5. Where to find Swift 3
  • 6. Where to find Swift 3 • Xcode 8 (Beta) • swift.org snapshots
  • 7. Considerations • You can only submit apps using Swift 3 when Xcode GM is shipped ~end of 2016. • Swift 3 changes everything. Xcode 8 comes with a code migration tool (can migrate to 2.3). However, I would still check the migrations made by Xcode.
  • 8. A Swift more “Swifty”
  • 9. Swift more “Swifty” • Not terse or Verbose code. • Clarity is more important than brevity. • Concise code is a consequence of using contextual cues. • What they mean (In my option) is: Let’s ditch legacy ObjC API designs, and be more “Swifty”.
  • 10. Before: After: NSTimer.scheduledTimerWithTimeInterval(0.35, target: self, …) NSTimer.scheduledTimer(timeInterval: 0.35, target: self, …) UIFont.preferredFontForTextStyle(UIFontTextStyleSubheadline) UIFont.preferredFont(forTextStyle: UIFontTextStyleSubheadline) func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? func viewForZooming(in scrollView: UIScrollView) -> UIView? Swift 2 Swift 3
  • 11. Before: After: func findCocoaheads(in city: String) { //... } findCocoaheads(in:"São Paulo") func findCocoaheadsIn(city: String) { //... } findCocoaheadsIn("São Paulo") Swift 2 Swift 3
  • 12. Before: After: UIColor.blueColor() UIColor.blue() // or simply .blue() if the compile can infer cocoaheads(insert: “São Paulo” atIndex: 0) cocoaheads(insert: “São Paulo” at: 0) NSUserDefaults.standardUserDefaults() UserDefaults.standard() // NSUserDefaults was renamed to UserDefaults Swift 2 Swift 3 Omitting needless words
  • 15. Example let dateComponent = NSDateComponents() dateComponent.year = 2016 let anotherComponent = dateComponent anotherComponent.year = 2017 //`dateComponent` year was also changed to 2017 var dateComponent = DateComponents() dateComponent.year = 2016 // It will warn you if `dateComponent` is a `let` let anotherComponent = dateComponent anotherComponent.year = 2017 //`dateComponent` is still 2016 Before: Swift 2 After: Swift 3
  • 17. Safety Increased Before: After: var cocoaheads = [String!]() cocoaheads.append("São Paulo") let sp = cocoaheads[0] sp.dynamicType // ImplicitlyUnwrappedOptional<String> Swift 2 Swift 3 var cocoaheads = [String!]() cocoaheads.append("São Paulo") let sp = cocoaheads[0] sp.dynamicType // Optional<String> let dangerousSp: String! = cocoaheads[0] dangerousSp.dynamicType // ImplicitlyUnwrappedOptional<String> No more `ImplicitlyUnwrappedOptional` propagation
  • 19. Coolness with SPM • The ability to pass custom flags during linker invocations. Also on C and Swift compilation. • Export as dynamic library == • Easy to Interoperate with other languages
  • 20. Coolness with SPM • Examples: • SwiftyRuby - Calling Ruby from Swift • SwiftyJava - Calling Java from Swift
  • 22. Conclusion • Swift 3 changes everything (again). It will force us get rid of our ObjC muscle muscle memory. • Was also brought by the community. We can always go on Github to complain, suggest and change. • There are many others news things that weren’t mentioned at this presentation, so don’t forget to check online for other things.
  • 23. Thanks! • Twitter: @marciok • Github: /marciok • References: • https://www.raywenderlich.com/135655/whats-new- swift-3 • https://www.bignerdranch.com/blog/wwdc-2016- increased-safety-in-swift-3/ • https://developer.apple.com/videos/play/wwdc2016/402/