Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Objective-Cで書かれたアプリをSwift化したときの話
Search
kuroyam
June 08, 2016
Programming
450
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Objective-Cで書かれたアプリをSwift化したときの話
shibuya.swift #4
kuroyam
June 08, 2016
More Decks by kuroyam
See All by kuroyam
iOS13でもSwiftUIでLazyなGridを実装したい! / use SwiftUI on iOS13
kuroyam
1
1.3k
開発合宿で バーチャルオフィス を作ろうとしたお話 / Let's Babiniku !
kuroyam
0
2.4k
アプリ設計改善の旅路
kuroyam
1
1.1k
途中からSwiftLint
kuroyam
1
660
Other Decks in Programming
See All in Programming
Are APIs Still Relevant in the AI Era?
soyuka
0
440
Vue Fes Japan の “作る側”に関わってみて
naokihaba
0
140
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.6k
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
470
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
390
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
530
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
310
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
130
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
740
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
520
Featured
See All Featured
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
540
Leo the Paperboy
mayatellez
10
2.4k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Building the Perfect Custom Keyboard
takai
2
900
Large-scale JavaScript Application Architecture
addyosmani
516
110k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
510
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
580
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
A designer walks into a library…
pauljervisheath
211
25k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
550
Code Reviewing Like a Champion
maltzj
529
40k
Transcript
Objective-CͰॻ͔Ε ͨΞϓϦΛSwiftԽ͠ ͨͱ͖ͷ @ shibuya.swift #4
͜Μʹͪ • ࠇా ॣ (@kuroyam) • GMOϖύϘגࣜձࣾ • ϞόΠϧΞϓϦͳΜͰ͞Μ •
ήʔϜ → Android → iOS
ࠓ͢͜ͱ
30daysAlbum • ࣸਅڞ༗αʔϏε • iOS൛ϦϦʔε2011 ( iOS4 ~ 5 )
• WebαʔϏεͱͯ͠2008͔Β • 20148݄͔Β͕iOS୲(1ਓ)
ΛSwiftԽͨ͠ͱ͖ͷʂ
ϓϥΠϕʔτͰSwiftॻ͍ͯΔ ͚ͲɺࣄͰObjective-Cॻ ͍ͯΔɾɾɾͬͯਓ͚Ͱ͢
1. େมͩͬͨ͜ͱ 2. ͏·͍ͬͨ͘͜ͱ 3. ޙչͯ͠Δ͜ͱ ͷ3ͭΛ͠·͢
ͦͷલʹɾɾɾ
͖͔͚ͬ • ϓϥΠϕʔτͰSwiftΛॻ͍͍ͯͨΒ Objective-C͕ͭΒ͘ͳ͖ͬͯͨ • Լ͕͍ͬͯ͘Ϟνϕʔγϣϯ • ૣ͘ՈʹؼͬͯSwiftॻ͖͍ͨ
Ͳ͏ͤiOS൛։ൃͯ͠Δͷ ҰਓͳΜͩ͠ɺউखʹͬͨ Β͍͍ͷͰʂ
ݱࡏͰ • 1ը໘Λআ͍ͯViewController͕Swiftʹͳͬͨ • ModelΫϥε΄΅ͯ͢Swiftʹͳͬͨ • ͦͷଞɺԿΒ͔ͷλεΫܥΫϥεͱ͔ϢʔςΟ ϦςΟܥΫϥεObjective-Cͷ··
݁Ռͱͯ͠ • ίʔυॻ͖͍͢ʂಡΈ͍͢ʂ • ։ൃupʂ • όά͕ݮͬͨɺग़ʹ͘͘ͳͬͨ • σϝϦοτಛʹແ͠
େมͩͬͨ͜ͱ
iOS7 • ࣌Γ͍͚ͨͲແࢹͰ͖ͳׂ͍߹ͰiOS7 Ϣʔβʔ͕͍ͨ • SwiftͷϥΠϒϥϦΛ͍͍ͨɾɾɾʂ • Objective-CCocoapodsͰɺSwift git submodule
ͰೖΕͨ
ΓͮΒ͍ͱ͜Ζ • Ϟϯελʔ ViewController • 1000ߦ͕͑Ұຕ͋Δ • ؔ࿈͢ΔViewଟ͍ͷͰ͕͔͔࣌ؒΔ • ModelΫϥε
• มߋͨ࣌͠ͷӨڹൣғ͕͍ͷͰ͜Θ͍ • ςετ͕ͳ͍ɾɾɾ
Ͳ͏͠Α͏ͳ͔ͬͨͭ • Objective-C͔ΒSwiftͷenumΛ͍͍ͨ • Objective-C͔ΒSwiftͷInt?ɺBool?Λࢀর͠ ͍ͨ • ٽ͘ٽ͘ϥούʔΛ࡞ͬͨ
͏·͍ͬͨ͘͜ͱ
View͔Β࢝ΊΔ • ৽نͰViewΛ࡞Δͱ͖ʹࢼ͠ʹSwiftͰॻ͍ͯ Έͨͷ͕࠷ॳ • ଞʹൺͯখ͘͞ɾૄ݁߹ • ػೳ։ൃͷؒʹখ͍͞View͔ΒͲΜͲΜSwift Խ
نେ͖Ίͷ༷มߋ͕͋ͬͨ • API࡞Γ͠ʂ • ΞϓϦଆͷModel࡞Γ͟͞ΔΛಘͳ͔ͬͨ • ͔ͤͬ͘ͳͷͰSwiftͰ… • λΠϛϯά͕Α͔͚ͬͨͩ…
ઃܭͷݟ͠Ͱ͖ͨ • ੲiOSք۾ͰઃܭͷΛ͢Δਓͬͯগͳ͔ͬ ͨ • ͳͷͰҾ͖ܧ͍ͩ࣌Ͱͷ͍͢͝ײ͡ͷ ίʔυʹͳͬͯͯͭΒ͔ͬͨ • ͪΌΜͱͨ͠ઃܭʹͤΔνϟϯε
ޙչͯ͠Δ͜ͱ
࠷ॳSwiftతʹ͍͍ॻ͖ํͰ ॻ͚ͳ͔ͬͨ
nilνΣοΫ͔Βͷforce unwrap if user != nil { user!.hoge() }
optional bindingͷ΄͏͕Α͍ if let user = user { user.hoge() }
// ͘͠ guard let user = user else { return } user.hoge()
ϧʔϓΛ·Θͯ͠ݕࡧ for product in products { if product.id == id
{ return product } }
ߴ֊ؔ͏ͱҰߦͰॻ͚Δ return products.filter{ $0.id == id }.first
͍͖ͳΓγϡοͱͨ͠ίʔυॻ ͚ͳ͍ • ΑΓΑ͍ॻ͖ํΛݟ͚ͭͨΒݹ͍ίʔυؚ Ίͯվળ͢ΔΑ͏ʹͯ͠Δ • ෳਓͰΔͳΒنͱ͔͋Δͱ໎͍ͳͯ͘ ศརͦ͏ • ૉৼΓେࣄ
ͱΓ͋͑ͣOptionalܕ
ͱΓ͋͑ͣOptionalܕʹ͠ͱ͜… class Book { var id: Int? var title: String?
var author: String? var createdAt: NSDate? . . . }
ࢀর͢Δͨͼʹ optional binding͢Δͷ ΊͬͪΌΊΜͲ͍ʂ
ۃྗOptionalܕʹ͠ͳ͍ • DBଆͰNotNullͳΒOptionalܕʹ͢Δඞཁͳ ͍ͷͰ • null͕ೖ͍ͬͯͨΒͦͦόάͩʂΈ͍ͨͳ ͷOptionalܕʹ͠ͳ͍΄͏͕͍͍͔ʁʁ • ྻۭͰॳظԽ͢Δ΄͏͕Αͦ͞͏
·ͱΊ
Swift͍͍ͧ • େ͖ͳΞϓϦ؆୯ʹSwiftԽͰ͖ͳ͍͔ ͠Εͳ͍͚ͲɺͰ͖Δͱ͔͜Β࢝Ί͍ͯ͜͏ • φͳݴޠͳͷͰָ͘͠ɺ҆શʹॻ͚ΔɻϞ νϕʔγϣϯͬͯ݁ߏॏཁ • ීஈϓϥΠϕʔτͰSwiftॻ͍ͯΔͱɺۀʹ ׆͔ͤͯͱͯΑ͍
ଞͷͱ͜ͷฉ͖͍ͨʂ • ͏ͪ͜͏ͨ͠Β͏·͍ͬͨ͘ʂͱ͔ • ͜͜ͰϋϚ͔ͬͨΒؾΛ͚ͭΖʂͱ͔ • ΈΜͳͰڠྗͯ͠SwiftͰָ͘͠ίʔσΟϯά ͍͖ͯ͠·͠ΐ͏ʂ