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
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Statistics for Hackers
jakevdp
796
220k
What's new in Ruby 2.0
geeforr
343
31k
Faster Mobile Websites
deanohume
305
30k
Speed Design
sergeychernyshev
24
610
Raft: Consensus for Rubyists
vanstee
136
6.6k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.2k
A better future with KSS
kneath
238
17k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
120
Documentation Writing (for coders)
carmenintech
65
4.4k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
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 Λҙࣝͯ͠ॻ͍͓ͯ͘ͱָ •
ίϯύΠϧΤϥʔղܾͷ͋ͱɺ৽ͨͳઓ͍͕࢝·Δ
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠