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.3k
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
950
Blending Kotlin's culture into Swift
ezura
1
1.2k
Featured
See All Featured
Statistics for Hackers
jakevdp
796
220k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Building Applications with DynamoDB
mza
90
6.1k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
329
21k
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Scaling GitHub
holman
458
140k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
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 Λҙࣝͯ͠ॻ͍͓ͯ͘ͱָ •
ίϯύΠϧΤϥʔղܾͷ͋ͱɺ৽ͨͳઓ͍͕࢝·Δ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠