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
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
We Have a Design System, Now What?
morganepeng
51
7.3k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Site-Speed That Sticks
csswizardry
2
190
[RailsConf 2023] Rails as a piece of cake
palkan
53
5k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Embracing the Ebb and Flow
colly
84
4.5k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Practical Orchestrator
shlominoach
186
10k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Gamification - CAS2011
davidbonilla
80
5.1k
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 Λҙࣝͯ͠ॻ͍͓ͯ͘ͱָ •
ίϯύΠϧΤϥʔղܾͷ͋ͱɺ৽ͨͳઓ͍͕࢝·Δ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠