Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Start using Swift.
Search
DAloG
January 14, 2016
Programming
1
110
Start using Swift.
DAloG
January 14, 2016
Tweet
Share
More Decks by DAloG
See All by DAloG
State normalization (RU)
dalog
0
160
Redux + MQTT
dalog
1
760
От задач к проблемам
dalog
1
220
Unlimited power of Data-Driven UI
dalog
4
600
Data-Driven View Controllers. Tips and Tricks
dalog
5
1.8k
2 years of Redux in iOS. Lessons learned
dalog
0
330
Why unidirectional architecture matter for iOS.
dalog
1
270
Mobile backend without REST
dalog
2
85
Self managed teams 101
dalog
0
130
Other Decks in Programming
See All in Programming
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
180
MCP with Cloudflare Workers
yusukebe
2
220
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
KubeCon + CloudNativeCon NA 2024 Overviewat Kubernetes Meetup Tokyo #68 / amsy810_k8sjp68
masayaaoyama
0
260
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.3k
Recoilを剥がしている話
kirik
5
6.8k
return文におけるstd::moveについて
onihusube
1
1.2k
採用事例の少ないSvelteを選んだ理由と それを正解にするためにやっていること
oekazuma
2
1k
創造的活動から切り拓く新たなキャリア 好きから始めてみる夜勤オペレーターからSREへの転身
yjszk
1
130
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
340
今年のアップデートで振り返るCDKセキュリティのシフトレフト/2024-cdk-security-shift-left
tomoki10
0
210
선언형 UI에서의 상태관리
l2hyunwoo
0
180
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Adopting Sorbet at Scale
ufuk
73
9.1k
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
A Modern Web Designer's Workflow
chriscoyier
693
190k
The Art of Programming - Codeland 2020
erikaheidi
53
13k
Six Lessons from altMBA
skipperchong
27
3.5k
Bash Introduction
62gerente
608
210k
The Pragmatic Product Professional
lauravandoore
32
6.3k
Agile that works and the tools we love
rasmusluckow
328
21k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Transcript
20.01.2016 Forget Objective-C. Start Swift. for Kharkiv Mobile Devs #15
Alexey Demedetskiy ✤ twitter: @DAlooG ✤ email:
[email protected]
✤ skype:
nobidon
Objective-C ✤ KVO/KVC ✤ UIKit ✤ Monolithic namespace ✤ Partially
defined behavior ✤ CoreData
Swift ✤ Closures ✤ Immutability ✤ Value types ✤ Generics
✤ Optionals
Swift ✤ Protocols ✤ Nested types ✤ Static ✤ Default
values ✤ Operators
How to Swift? ✤ Add Swift to existing project ✤
Start new project
Why? ✤ Strong types —> Less errors ✤ More instruments
—> Cleaner code ✤ Better syntax —> Easy to read and write
Optionals vs ‘nil’
nil ✤ [nil aMessage:@«text»] - ✅ ✤ [list addObject:nil] -
❌
Optional<T> ✤ T! ✤ T? ✤ T
Dirty Types ✤ UIKit ✤ External data (Network etc) ✤
Objective-C
How to clear types? ✤ as? : Any -> T?
✤ as! : Any -> T
None
None
None
WTF Immutability. ✤ Reference and Value types ✤ let -
immutable name ✤ var - mutable name
Struct trickery ✤ How many objects will be created? ✤
How many times `print` will write? ✤ What `t1.b` will print?
Struct trickery ✤ 0. There is no objects. ✤ 1.
✤ 4.
Class trickery ✤ How many objects will be created? ✤
How many times `print` will write? ✤ What `t1.b` will print?
Class trickery ✤ 1 ✤ 1 ✤ -1
let == const?
let == const?
Value types Pros ✤ Immutable. Even with `var` ✤ `init`
from compiler ✤ No inheritance
Properties ✤ no setter / getter methods. ✤ …unless `dynamic`
is specified ✤ `willSet` / `didSet` with references to new/old values ✤ `public private(set) var …` is ok
enum vs NS_ENUM
enum vs NS_ENUM
Shadow types!
None
None
When use enum? ✤ Flags ✤ States ✤ Options ✤
Shadow type
Alamofire vs AFNetworking
Namespaces ✤ Nested types ✤ Frameworks ✤ Targets
Nested types
Nested types
Nested types
Nested types
Nested types
let = vs dispatch_once
Outro ✤ Run away from Obj-C ✤ Build your own
logic modules ✤ Use Value Types ✤ Don’t use generics + inheritance + UIKit