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
150
Redux + MQTT
dalog
1
730
От задач к проблемам
dalog
1
170
Unlimited power of Data-Driven UI
dalog
4
580
Data-Driven View Controllers. Tips and Tricks
dalog
5
1.7k
2 years of Redux in iOS. Lessons learned
dalog
0
320
Why unidirectional architecture matter for iOS.
dalog
1
260
Mobile backend without REST
dalog
2
72
Self managed teams 101
dalog
0
120
Other Decks in Programming
See All in Programming
Apache Hive 4 on Treasure Data
ryukobayashi
1
420
Java 22 Overview
kishida
1
190
ServerAction で Progressive Enhancement はどこまで頑張れるか? / progressive-enhancement-with-server-action
takefumiyoshii
6
420
AWS CDKコントリビュートTIPS / aws-cdk-contribution-tips
gotok365
4
380
効率化に挑戦してみたらモバイル開発が少し快適になった話
ryunakayama
0
140
禅の心を手に入れよ
eltociear
1
340
"config" ってなんだ? / What is "config"?
okashoi
0
310
大規模Reactアプリのリアーキテクチャ~8万行のTanStack Query移行の軌跡~
kj455
4
1k
サイコロで理解する統計的仮説検定の考え方
tatamiya
4
1k
Netty Chicago Java User Group 2024-04-17
sullis
0
200
#phpcon_odawara オープン・クローズドなテストフィクスチャを求めて / open closed test fixtures
77web
3
240
Tailwind CSSを本気でカスタマイズする方法
fsubal
14
5.5k
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
75
5.2k
Fantastic passwords and where to find them - at NoRuKo
philnash
39
2.5k
[RailsConf 2023] Rails as a piece of cake
palkan
27
4k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
65
14k
Adopting Sorbet at Scale
ufuk
69
8.6k
Optimizing for Happiness
mojombo
370
69k
Infographics Made Easy
chrislema
238
18k
WebSockets: Embracing the real-time Web
robhawkes
59
7k
How to Ace a Technical Interview
jacobian
273
22k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
501
140k
Happy Clients
brianwarren
92
6.4k
What’s in a name? Adding method to the madness
productmarketing
PRO
17
2.7k
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