SlideShare a Scribd company logo
1 of 27
Download to read offline
Swift
Swift?
Dážďovník Obyčajný [SK]
— similar to swallow
— max. 169km/h
— cca. 200 000 km per year
Swift
— innovative new programming language for Cocoa and
Cocoa Touch
— introduced during WWDC 2014
— for iOS 7+
— for OS X 10.9+ (Mavericks, Yosemite, ...)
Nice Syntax
class Person {
func makeHello(who: String) -> String {
return "Hello, (who)!"
}
}
@interface Person : NSObject
- (NSString *)makeHello:(NSString *)who;
@end
@implementation Person
- (NSString *)makeHello:(NSString *)who {
return [NSString stringWithFormat:@"Hello, %@!", who];
}
@end
Full Unicode Support
// Swift
let smileAndCry = "!"
let " = "like"
// Objective-C
Type Safety
— encourages to be clear about the types
— type checks during compilation
— type inference
Type Inference
// these constants are of same type
let str1: String = "Foo"
let str2 = "Bar"
_stdlib_getDemangledTypeName(str1) // Swift.String
_stdlib_getDemangledTypeName(str2) // Swift.String
Functional Programming
objc.io/books
Immutability
let str = "Hello, World!"
str = "Good bye!" // error
let arr = ["item1", "item2", "item3"]
arr.append("item4") // error
struct Counter {
var count = 0
mutating func increment() {
count++
}
}
Optionals
var sureThing: String
var maybeNot: String?
maybeNot = "I might not be here"
sureThing = maybeNot // error
if let maybeConfirmed = maybeNot {
sureThing = maybeConfirmed
}
var dict = [String:String]()
dict["non_existent_key"] ?? "fallbackValue"
Tuples
— good for returning multiple results from a
function / method
func dices() -> (dice1: Int, dice2: Int) {
let d1 = Int(arc4random_uniform(6)) + 1
let d2 = Int(arc4random_uniform(6)) + 1
return (dice1: d1, dice2: d2)
}
let roll = dices()
roll.dice1 // something from 1...6
roll.dice2 // something from 1...6
Structs
struct Weather {
var temperature: Float
var sunny: Bool
func isForSunglasses () -> Bool {
return sunny
}
}
var perfectWeather = Weather(temperature: 30, sunny: true)
perfectWeather.temperature // 30
perfectWeather.sunny // true
Almost the same as a class, but it's a value type.
Value & Reference Types
struct Weather {
var temperature: Float
var sunny: Bool
}
var perfectWeather = Weather(temperature: 30, sunny: true)
var cloudyWeather = perfectWeather
cloudyWeather.sunny = false
perfectWeather.sunny // true - no change, because cloudyWeather have been copied and not referenced
Pattern Matching
— switch - no fallthrough
case 1..<10:
case (x, y) where x == y:
case .North:
case is UITableView:
Generics
— Array & Dictionary in Swift are generic
collections
func swapTwoValues<T>(inout a: T, inout b: T) {
let temporaryA = a
a = b
b = temporaryA
}
Generators, Sequences
protocol Generator {
typealias Element
func next() -> Element?
}
for i in 1…10 {
// do something
}
Custom Operators
infix operator >>> { associativity left }
func >>> (filter1: Filter, filter2: Filter) -> Filter {
return { img in filter2(filter1(img)) }
}
let myFilter2 = blur(blurRadius) >>> colorOverlay(overlayColor)
let result2 = myFilter2(image)
1
1
Excerpt From: “Functional Programming in Swift.“
REPL
Read-Eval-Print-Loop (XCode, Terminal)
1.1
— failable initializers
extension Int {
init?(fromString: String) {
if let i = fromString.toInt() {
self = i
} else {
return nil
}
}
}
— less SourceKitService crashes
1.2
— migrator
— less SourceKitService crashes
— let constant must be initialized before use
if let a = foo(), b = bar() where a < b,
let c = baz() {
}
Swift Or Not To Swift?
!
— Education
— New Projects
— Experimenting
— Standalone libraries
Swift Or Not To Swift?
!
— Legacy Projects
— C++ In Project
— Support For iOS6 and older
Thank You
Questions?

More Related Content

What's hot

Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax BasicsRichard Paul
 
Class array
Class arrayClass array
Class arraynky92
 
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiiOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiMarin Benčević
 
Introduction to Vim, the text editor
Introduction to Vim, the text editorIntroduction to Vim, the text editor
Introduction to Vim, the text editorVysakh Sreenivasan
 
Practical TypeScript
Practical TypeScriptPractical TypeScript
Practical TypeScriptldaws
 
4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)
4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)
4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)PROIDEA
 
An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12Digiflare
 
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swiftみんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swiftTomohiro Kumagai
 
C++ question 6 || solution of Programming Problem
C++ question 6 || solution of Programming Problem C++ question 6 || solution of Programming Problem
C++ question 6 || solution of Programming Problem Topics MixeR
 
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swiftみんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swiftTomohiro Kumagai
 
20090622 Vimm4
20090622 Vimm420090622 Vimm4
20090622 Vimm4id774
 
UTAU DLL voicebank and ulauncher
UTAU DLL voicebank and ulauncherUTAU DLL voicebank and ulauncher
UTAU DLL voicebank and ulauncherhunyosi
 
Cloud Erlang
Cloud ErlangCloud Erlang
Cloud ErlangNgoc Dao
 
Reacting with ReactiveUI
Reacting with ReactiveUIReacting with ReactiveUI
Reacting with ReactiveUIkiahiska
 

What's hot (19)

Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
Class array
Class arrayClass array
Class array
 
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksiiOS Talks 1 - CodeCamp Osijek - Swift u praksi
iOS Talks 1 - CodeCamp Osijek - Swift u praksi
 
Introduction to Vim, the text editor
Introduction to Vim, the text editorIntroduction to Vim, the text editor
Introduction to Vim, the text editor
 
Practical TypeScript
Practical TypeScriptPractical TypeScript
Practical TypeScript
 
4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)
4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)
4Developers 2018: RxJS: Everything is a stream (Tomasz Ducin)
 
An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12An Introduction to WebWorker - 01.26.12
An Introduction to WebWorker - 01.26.12
 
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swiftみんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
みんなで Swift 復習会での談笑用スライド – 2nd #minna_de_swift
 
C++ question 6 || solution of Programming Problem
C++ question 6 || solution of Programming Problem C++ question 6 || solution of Programming Problem
C++ question 6 || solution of Programming Problem
 
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swiftみんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
みんなで Swift 復習会での談笑用スライド – in 札幌 1st′ #minna_de_swift
 
20090622 Vimm4
20090622 Vimm420090622 Vimm4
20090622 Vimm4
 
UTAU DLL voicebank and ulauncher
UTAU DLL voicebank and ulauncherUTAU DLL voicebank and ulauncher
UTAU DLL voicebank and ulauncher
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Cloud Erlang
Cloud ErlangCloud Erlang
Cloud Erlang
 
Date function
Date functionDate function
Date function
 
Class ‘increment’
Class ‘increment’Class ‘increment’
Class ‘increment’
 
Reacting with ReactiveUI
Reacting with ReactiveUIReacting with ReactiveUI
Reacting with ReactiveUI
 
Include
IncludeInclude
Include
 
20151224-games
20151224-games20151224-games
20151224-games
 

Viewers also liked

Cv rodrigo aparecido morales - trad
Cv   rodrigo aparecido morales - tradCv   rodrigo aparecido morales - trad
Cv rodrigo aparecido morales - tradRodrigo Morales
 
CV Fernando Melo 2015
CV Fernando Melo 2015CV Fernando Melo 2015
CV Fernando Melo 2015Fernando Melo
 
посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...
посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...
посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...Аліна Плєханова
 
Network Vulnerability and Patching
Network Vulnerability and PatchingNetwork Vulnerability and Patching
Network Vulnerability and PatchingEmmanuel Udeagha B.
 
Additive Manufacturing -3D Printing
Additive Manufacturing -3D PrintingAdditive Manufacturing -3D Printing
Additive Manufacturing -3D PrintingTimothy McDougald
 
Après midi détente 2013 aux chambres d'hôtes Aux Vieux Chênes
Après midi détente 2013 aux chambres d'hôtes Aux Vieux ChênesAprès midi détente 2013 aux chambres d'hôtes Aux Vieux Chênes
Après midi détente 2013 aux chambres d'hôtes Aux Vieux ChênesChambres d'hôtes Aux Vieux CHênes
 

Viewers also liked (11)

Cv rodrigo aparecido morales - trad
Cv   rodrigo aparecido morales - tradCv   rodrigo aparecido morales - trad
Cv rodrigo aparecido morales - trad
 
CV Fernando Melo 2015
CV Fernando Melo 2015CV Fernando Melo 2015
CV Fernando Melo 2015
 
GROUP 9 EBAY
GROUP 9 EBAY GROUP 9 EBAY
GROUP 9 EBAY
 
PRESENTATION TC SALONICA
PRESENTATION TC SALONICAPRESENTATION TC SALONICA
PRESENTATION TC SALONICA
 
посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...
посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...
посібник для працівників органів внутрішніх справ на місцевих виборах 25 жовт...
 
Network Vulnerability and Patching
Network Vulnerability and PatchingNetwork Vulnerability and Patching
Network Vulnerability and Patching
 
Additive Manufacturing -3D Printing
Additive Manufacturing -3D PrintingAdditive Manufacturing -3D Printing
Additive Manufacturing -3D Printing
 
shanusharma
shanusharmashanusharma
shanusharma
 
La planète Jupiter
La planète JupiterLa planète Jupiter
La planète Jupiter
 
StratégieContenu
StratégieContenuStratégieContenu
StratégieContenu
 
Après midi détente 2013 aux chambres d'hôtes Aux Vieux Chênes
Après midi détente 2013 aux chambres d'hôtes Aux Vieux ChênesAprès midi détente 2013 aux chambres d'hôtes Aux Vieux Chênes
Après midi détente 2013 aux chambres d'hôtes Aux Vieux Chênes
 

Similar to CocoaHeads Bratislava #1 - Swift

Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practicesIwan van der Kleijn
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard LibrarySantosh Rajan
 
Maclennan chap5-pascal
Maclennan chap5-pascalMaclennan chap5-pascal
Maclennan chap5-pascalSerghei Urban
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-CNissan Tsafrir
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesEelco Visser
 
Introduction to c
Introduction to cIntroduction to c
Introduction to cSayed Ahmed
 
Kotlin: maybe it's the right time
Kotlin: maybe it's the right timeKotlin: maybe it's the right time
Kotlin: maybe it's the right timeDavide Cerbo
 
Hello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebHello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebMuhammad Raza
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6Nitay Neeman
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for KotlinTechMagic
 
Back to the Future with TypeScript
Back to the Future with TypeScriptBack to the Future with TypeScript
Back to the Future with TypeScriptAleš Najmann
 
Funtional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTFuntional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTVasil Remeniuk
 
Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Jung Kim
 

Similar to CocoaHeads Bratislava #1 - Swift (20)

Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practices
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
Maclennan chap5-pascal
Maclennan chap5-pascalMaclennan chap5-pascal
Maclennan chap5-pascal
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-C
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
scalar.pdf
scalar.pdfscalar.pdf
scalar.pdf
 
Swift, swiftly
Swift, swiftlySwift, swiftly
Swift, swiftly
 
Ti1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and ScopesTi1220 Lecture 2: Names, Bindings, and Scopes
Ti1220 Lecture 2: Names, Bindings, and Scopes
 
Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Kotlin: maybe it's the right time
Kotlin: maybe it's the right timeKotlin: maybe it's the right time
Kotlin: maybe it's the right time
 
Hello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebHello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC Unideb
 
Getting started with ES6
Getting started with ES6Getting started with ES6
Getting started with ES6
 
Start with swift
Start with swiftStart with swift
Start with swift
 
Scala - brief intro
Scala - brief introScala - brief intro
Scala - brief intro
 
Intro toswift1
Intro toswift1Intro toswift1
Intro toswift1
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Back to the Future with TypeScript
Back to the Future with TypeScriptBack to the Future with TypeScript
Back to the Future with TypeScript
 
Funtional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWTFuntional Reactive Programming with Examples in Scala + GWT
Funtional Reactive Programming with Examples in Scala + GWT
 
Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법Swift와 Objective-C를 함께 쓰는 방법
Swift와 Objective-C를 함께 쓰는 방법
 
Protocol-Oriented MVVM
Protocol-Oriented MVVMProtocol-Oriented MVVM
Protocol-Oriented MVVM
 

Recently uploaded

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
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) SolutionOnePlan Solutions
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
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 TechniquesVictorSzoltysek
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 

Recently uploaded (20)

WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
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
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
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
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 

CocoaHeads Bratislava #1 - Swift

  • 3.
  • 4. Dážďovník Obyčajný [SK] — similar to swallow — max. 169km/h — cca. 200 000 km per year
  • 5.
  • 6. Swift — innovative new programming language for Cocoa and Cocoa Touch — introduced during WWDC 2014 — for iOS 7+ — for OS X 10.9+ (Mavericks, Yosemite, ...)
  • 7. Nice Syntax class Person { func makeHello(who: String) -> String { return "Hello, (who)!" } } @interface Person : NSObject - (NSString *)makeHello:(NSString *)who; @end @implementation Person - (NSString *)makeHello:(NSString *)who { return [NSString stringWithFormat:@"Hello, %@!", who]; } @end
  • 8. Full Unicode Support // Swift let smileAndCry = "!" let " = "like" // Objective-C
  • 9. Type Safety — encourages to be clear about the types — type checks during compilation — type inference
  • 10. Type Inference // these constants are of same type let str1: String = "Foo" let str2 = "Bar" _stdlib_getDemangledTypeName(str1) // Swift.String _stdlib_getDemangledTypeName(str2) // Swift.String
  • 12. Immutability let str = "Hello, World!" str = "Good bye!" // error let arr = ["item1", "item2", "item3"] arr.append("item4") // error struct Counter { var count = 0 mutating func increment() { count++ } }
  • 13. Optionals var sureThing: String var maybeNot: String? maybeNot = "I might not be here" sureThing = maybeNot // error if let maybeConfirmed = maybeNot { sureThing = maybeConfirmed } var dict = [String:String]() dict["non_existent_key"] ?? "fallbackValue"
  • 14. Tuples — good for returning multiple results from a function / method func dices() -> (dice1: Int, dice2: Int) { let d1 = Int(arc4random_uniform(6)) + 1 let d2 = Int(arc4random_uniform(6)) + 1 return (dice1: d1, dice2: d2) } let roll = dices() roll.dice1 // something from 1...6 roll.dice2 // something from 1...6
  • 15. Structs struct Weather { var temperature: Float var sunny: Bool func isForSunglasses () -> Bool { return sunny } } var perfectWeather = Weather(temperature: 30, sunny: true) perfectWeather.temperature // 30 perfectWeather.sunny // true Almost the same as a class, but it's a value type.
  • 16. Value & Reference Types struct Weather { var temperature: Float var sunny: Bool } var perfectWeather = Weather(temperature: 30, sunny: true) var cloudyWeather = perfectWeather cloudyWeather.sunny = false perfectWeather.sunny // true - no change, because cloudyWeather have been copied and not referenced
  • 17. Pattern Matching — switch - no fallthrough case 1..<10: case (x, y) where x == y: case .North: case is UITableView:
  • 18. Generics — Array & Dictionary in Swift are generic collections func swapTwoValues<T>(inout a: T, inout b: T) { let temporaryA = a a = b b = temporaryA }
  • 19. Generators, Sequences protocol Generator { typealias Element func next() -> Element? } for i in 1…10 { // do something }
  • 20. Custom Operators infix operator >>> { associativity left } func >>> (filter1: Filter, filter2: Filter) -> Filter { return { img in filter2(filter1(img)) } } let myFilter2 = blur(blurRadius) >>> colorOverlay(overlayColor) let result2 = myFilter2(image) 1 1 Excerpt From: “Functional Programming in Swift.“
  • 22. 1.1 — failable initializers extension Int { init?(fromString: String) { if let i = fromString.toInt() { self = i } else { return nil } } } — less SourceKitService crashes
  • 23. 1.2 — migrator — less SourceKitService crashes — let constant must be initialized before use if let a = foo(), b = bar() where a < b, let c = baz() { }
  • 24. Swift Or Not To Swift? ! — Education — New Projects — Experimenting — Standalone libraries
  • 25. Swift Or Not To Swift? ! — Legacy Projects — C++ In Project — Support For iOS6 and older