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
iO
Search
Yuka Ezura
November 20, 2016
0
75
iO
Yuka Ezura
November 20, 2016
Tweet
Share
More Decks by Yuka Ezura
See All by Yuka Ezura
Mastering share sheet preview
ezura
4
1.3k
SF Symbols
ezura
9
1.2k
気遣いの iOS プログラミング
ezura
11
3.4k
Secret Swift tour
ezura
7
2.8k
Swift Album ver.4.1
ezura
3
1.4k
Swift と Kotlin
ezura
4
2.6k
哲学とSwiftの発表
ezura
5
580
アプリが動いたその先へ (iOS アプリ開発編)
ezura
1
970
Blending Kotlin's culture into Swift
ezura
1
1.2k
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.2k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
510
Making Projects Easy
brettharned
116
5.9k
Visualization
eitanlees
146
15k
Automating Front-end Workflow
addyosmani
1366
200k
Thoughts on Productivity
jonyablonski
67
4.4k
Why Our Code Smells
bkeepers
PRO
335
57k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Become a Pro
speakerdeck
PRO
26
5k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
A designer walks into a library…
pauljervisheath
204
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
95
17k
Transcript
iOS ք۾ Swift3 Ҡߦͷҋ ezura
iOS ΤϯδχΞͷਓ
iOS ΤϯδχΞͱࣄͯ͠Δਓ
·ͩɺଉͯ͠·͔͢ (´ɾωɾʆ)ʁ
"\(self)" • ezura • iOS ΤϯδχΞ • ࠷ۙ Swift2 ͔Β
Swift3 ͷҠߦͷ͓ࣄ
"\(self)" • ezura • iOS ΤϯδχΞ • ࠷ۙ Swift2 ͔Β
Swift3 ͷҠߦͷ͓ࣄ
͍͑ͨ͜ͱ
Swift3 ରԠ͍ͯ͠ͳ͍ iOS ΤϯδχΞͷํ ֮ޛ͍ͯͩ͘͠͞
iOS ΤϯδχΞͱࣄ͍ͯ͠Δํ ԾʹɺSwift3 Ҡߦͷਐḿ͕ѱͯ͘ ͝ཧղͷ΄ͲɺΑΖ͓͘͠ئ͍͠·͢…
Index • ҋʹࢸΔܦҢ • ҋΛΓӽ͑ΔͨΊʹ • Swift3 ͷॻ͖͑ޙʹൃੜͨ͜͠ͱ
ҋʹࢸΔܦҢ
Ή͔͠Ή͔͠ɺ iOS ΞϓϦ Objective-C ͱ͍͏ݴޠͰ ॻ͘͜ͱ͕ඪ४Ͱͨ͠
ಥવͷͷܒࣔ
Swift ͱ͍͏ݴޠΛ࡞ͬͨΑ ࠓޙ͜ΕΛਪ͍ͯ͘͠Α
༷ͷ࣊͝൵
(ͨͩ͠ɺ੍ݶ͋Γ) Objective-C ͱ Swift ૬ޓʹݺͼग़͢͜ͱ͕Ͱ͖·͢ Ὃ طଘͷίʔυͦͷ··༻Մೳ
͔ͯ͘͠ɺ iOS ΞϓϦ Objective-C ͱ Swift ͷ ࠞࡏ͢ΔੈքͱͳΓ·ͨ͠
৽͘͠ॻ͘෦ Swift2 ʹ͠Α͏ ͱ͍͏ྲྀΕ
طଘͷίʔυ Swift2 ʹஔ͖͑Α͏ͱ͍͏ಈ͖
ฏ͕๚Ε…
Swift3 ϦϦʔε ഁյతΞοϓσʔτ
Xcode8.2 (࣍ͷόʔδϣϯ) Λ ࠷ޙʹ Swift2 ͷαϙʔτΛΔΑ
Swift3 ͷҠߦۙʑඞਢʹ
ͱ͍͑ɺ3 ͘Β͍ͰऴΘΔͰ͠ΐʁ Conversion πʔϧ͋Δ͠…
Θͨ͋ΊͷΑ͏ʹ͍ߟ͑Ͱͨ͠
Error 0 200 400 600 800 1 2
3 4 5 6 7 8 9 Τϥʔ (ୀࣾ࣌)
Կ͕͋ͬͨͷ͔ • ҰʹΤϥʔΛݕग़Ͱ͖ͳ͍ • ίϯόʔδϣϯπʔϧ͕·ͱʹಈ͔ͳ͍ • Swift ͱ Objective-C ͷ࿈ܞͷมߋ༝དྷͰɺةݥͳ
෦͕͋Δ • ϥΠϒϥϦ෦ͷมߋશͯࣗͰ • ϥϯλΠϜΤϥʔɺҙਤ͠ͳ͍ڍಈͷରԠ
Կ͕͋ͬͨͷ͔ • ҰʹΤϥʔΛݕग़Ͱ͖ͳ͍ • ίϯόʔδϣϯπʔϧ͕·ͱʹಈ͔ͳ͍ • Swift ͱ Objective-C ͷ࿈ܞͷมߋ༝དྷͰɺةݥͳ
෦͕͋Δ • ϥΠϒϥϦ෦ͷมߋશͯࣗͰ • ϥϯλΠϜΤϥʔɺҙਤ͠ͳ͍ڍಈͷରԠ
Error 0 200 400 600 800 1 2
3 4 5 6 7 8 9 Τϥʔ (ୀࣾ࣌)
ҋΛΓӽ͑ΔͨΊʹ
Swift2 ͷ͏͔ͪΒରࡦ͢Δ
Swift2 Ͱॻ͍͍ͯΔਓ • Swift ίʔσΟϯάΨΠυϥΠϯʹଇͬͯॻ͍͓ͯ ͖·͠ΐ͏ • Objective-C ͱͷ࿈ܞͰ IUO
ΛΘͣ Optional Ͱ ѻ͏Α͏ʹ͠·͠ΐ͏ (nullability ΞϊςʔγϣϯΛࢦఆ͍ͯ͠ͳ͍߹) • RxSwift ͷഇࢭ༧ఆͷϝιου (`onNext` ) ΛΘ ͳ͍Α͏ʹ͠·͠ΐ͏
ॻ͖·ͨ͠ʂ٩( 'ω' )و ࠓɺSwift2 Ͱॻ͍͍ͯΔಉ๔ୡɻ࠷ݶͬ ͓͖͍ͯͨɺSwift2 ͷ··Ͱ࢝ΊΔ Swift3 ରࡦ
Swift3 Ҡߦ్தͷਓ ಉࢤΑɺ͕Μͬͯ
Swift3 ίϯύΠϧΤϥʔղܾͷ ޙஊ
ϥϯλΠϜΤϥʔ • NSURL ͱ URL • Objective-C ͷδΣωϦοΫܕʹ Swift ͔ΒΞΫηε
(Swift2 Ͱେৎͩͬͨ…) • Objective-C Realm ࢮ͢ (ݹ͍όʔδϣϯͩͬͨͷཁҼ) • ϚΠάϨʔγϣϯπʔϧ͕ͱΓ͋͑ͣ `!` ͚ͭͯͨ
༧ظͤ͵ڍಈ • protocol ͷϝιου໊ͷม࿙Ε (optional ࢦఆ default ࣮͍ͯ͠Δϝιουͩͱ ؾ͕͖ͭʹ͍͘) •
ϚΠάϨʔγϣϯπʔϧ͕ྑ͘ͳ͍Ωϟετͯ͠Δ
·ͱΊ
• ༧Ҏ্ʹ Swift3 ରԠʹ͕͔͔࣌ؒΔ • Swift2 ͷ͏͔ͪΒ Swift3 Λҙࣝͯ͠ॻ͍͓ͯ͘ͱָ •
ίϯύΠϧΤϥʔղܾͷ͋ͱɺ৽ͨͳઓ͍͕࢝·Δ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠