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
Mobile Programming Protocol Extension
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
yuichiro_takahashi
January 29, 2019
Technology
0
86
Mobile Programming Protocol Extension
MobileProgrammingの授業で使うスライドです!
yuichiro_takahashi
January 29, 2019
Tweet
Share
More Decks by yuichiro_takahashi
See All by yuichiro_takahashi
Claude Code の Skill で複雑な既存仕様をすっきり整理しよう
yuichirokato
1
150
App Clip - in a nutshell
yuichirokato
0
370
巨大な機能を VIPER + MicroViewController でいい感じに実装した話
yuichirokato
1
830
Mobile Programming Protocol
yuichirokato
0
94
Mobile Programming enum
yuichirokato
0
180
Mobile Programming Optional
yuichirokato
0
140
Mobile Programming Struct
yuichirokato
0
140
Mobile Programming Initializer Beta
yuichirokato
0
130
Mobile Programming Inheritance
yuichirokato
0
160
Other Decks in Technology
See All in Technology
トラブルの大半は「言ってない」x「言ってない」じゃねーか!!
ichimichi
0
230
Claude Cowork Plugins を読む - Skills駆動型業務エージェント設計の実像と構造
knishioka
0
210
【PyCon mini Shizuoka 2026】生成AI時代に画像処理やオーディオ処理のノードエディターを作る理由
kazuhitotakahashi
0
220
Interop Tokyo 2025 ShowNet Team Memberで学んだSRv6を基礎から丁寧に
miyukichi_ospf
0
260
Serverless Agent Architecture on Azure / serverless-agent-on-azure
miyake
1
120
Secure Boot 2026 - Aggiornamento dei certificati UEFI e piano di adozione in azienda
memiug
0
120
LY Tableauでの Tableau x AIの実践 (at Tableau Now! - 2026-02-26)
yoshitakaarakawa
0
1.1k
全自動で回せ!Claude Codeマーケットプレイス運用術
yukyu30
3
150
研究開発部メンバーの働き⽅ / Sansan R&D Profile
sansan33
PRO
4
22k
JAWS DAYS 2026 CDP道場 事前説明会 / JAWS DAYS 2026 CDP Dojo briefing document
naospon
0
100
Microsoft Fabric のワークスペースと容量の設計原則
ryomaru0825
2
220
社内ワークショップで終わらせない 業務改善AIエージェント開発
lycorptech_jp
PRO
1
430
Featured
See All Featured
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
560
How To Stay Up To Date on Web Technology
chriscoyier
791
250k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
620
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
2
65
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
5.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.7k
Skip the Path - Find Your Career Trail
mkilby
0
71
Faster Mobile Websites
deanohume
310
31k
Visualization
eitanlees
150
17k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Color Theory Basics | Prateek | Gurzu
gurzu
0
220
Embracing the Ebb and Flow
colly
88
5k
Transcript
PROTOCOL EXTENSION MOBILE PROGRAMMING JAN 30TH
1. EXTENSION
ςΩετ EXTENSION? ▸ ҙͷClassStruct, ProtocolΛจࣈ௨Γ֦ுͰ͖Δݴޠػೳͷࣄ ▸ ͕ࣗఆٛͨ͠Class͚ͩͰͳ͘ɺ͢Ͱʹఆٛ͞Ε͍ͯΔClassͳ Ͳ֦ு͢Δ͜ͱ͕Մೳ(UIViewControllerͱ͔) ▸ ͜͜Ͱݴ͏֦ுͱϝιουϓϩύςΟͷՃ,
Protocolͷ࠾༻ Λࢦ͢ ▸ ඇৗʹศརͳػೳͰ͋Δ͕અΛकΒͳ͍֦ுࠇຐज़ͱݺ ΕڪΕΒΕ͍ͯΔ
ςΩετ EXTENSION(จ๏) extension String { } Ωʔϫʔυ extension ʹଓ͚ͯ ֦ு͍ͨ͠Class໊Λऔಘ
ςΩετ EXTENSION(จ๏) extension String { var length: Int { return
self.count } } Ωʔϫʔυ extension ʹଓ͚ͯ ֦ு͍ͨ͠Class໊Λࢦఆ PropertyΛՃͰ͖Δ͕ Computed Property ͷΈ
ςΩετ EXTENSION(จ๏) extension String { var length: Int { return
self.count } func toInt(with defaultValue: Int) -> Int { return Int(self) ?? defaultValue } } Ωʔϫʔυ extension ʹଓ͚ͯ ֦ு͍ͨ͠Class໊Λࢦఆ PropertyΛՃͰ͖Δ͕ Computed Property ͷΈ ϝιουClassͳͲͱಉ͡Α͏ʹՃՄೳ
ςΩετ EXTENSION(จ๏) extension String { var length: Int { return
self.count } func toInt(with defaultValue: Int) -> Int { return Int(self) ?? defaultValue } init(date: Date, format: String) { // ͘ͳΔͷͰׂѪ } } Ωʔϫʔυ extension ʹଓ͚ͯ ֦ு͍ͨ͠Class໊Λࢦఆ PropertyΛՃͰ͖Δ͕ Computed Property ͷΈ ϝιουClassͳͲͱಉ͡Α͏ʹՃՄೳ ΠχγϟϥΠβClassͳͲͱಉ͡Α͏ʹՃՄೳ
ςΩετ EXTENSION(จ๏ͦͷ̎) extension UIViewController: UITableViewDataSource { func numberOfSections(in tableView: UITableView)
-> Int { return 0 } // ͘ͳΔͷͰׂѪ } Class໊ʹଓ͚ͯProtocol໊Λࢦఆ
2. PROTOCOL EXTENSION
ςΩετ PROTOCOL EXTENSION? ▸ ઌ΄Ͳͨ͠ExtensionΛͬͯ ProtocolΛ֦ு͢Δࣄ ▸ ProtocolඇৗʹศརͳػೳͰ͋Δ͕ఆٛ͞ΕͨϝιουΛ ࠾༻͢Δͨͼʹ࣮͠ͳ͍͚ͯ͘ͳ͍ख͕ؒ͋Δ ▸
Protocol ExtensionΛͬͯProtocolʹσϑΥϧτͷ࣮Λ ࣋ͨͤͯखؒΛܰݮ͢Δ͜ͱ͕Ͱ͖Δ ▸
ςΩετ PROTOCOL EXTENSION(จ๏, ఆٛ) protocol DismissDelegate {} ·ͣProtocolΛఆٛ͢Δ͕֦ு͍ͨ͠ϝιουͬͪ͜ʹॻ͔ͳ͍
ςΩετ PROTOCOL EXTENSION(จ๏, ఆٛ) protocol DismissDelegate {} extension DismissDelegate {
} ·ͣProtocolΛఆٛ͢Δ͕֦ு͍ͨ͠ϝιουͬͪ͜ʹॻ͔ͳ͍ extension Ωʔϫʔυʹଓ͚ͯProtocol໊Λࢦఆ
ςΩετ PROTOCOL EXTENSION(จ๏, ఆٛ) protocol DismissDelegate {} extension DismissDelegate {
func dismiss(vc: UIViewController) { vc.dismiss(animated: true, completion: nil) } } ·ͣProtocolΛఆٛ͢Δ͕֦ு͍ͨ͠ϝιουͬͪ͜ʹॻ͔ͳ͍ extension Ωʔϫʔυʹଓ͚ͯProtocol໊Λࢦఆ ֦ு͍ͨ͠ϝιουΛ࣮
ςΩετ PROTOCOL EXTENSION(จ๏, ࠾༻ଆ) class ViewController: UIViewController { } extension
ViewController: DismissDelegate {} ֦ுͨ͠ProtocolΛ࠾༻ͤ͞Δ͕࣮Λॻ͘ඞཁ͕ແ͍ʂʂ
ςΩετ PROTOCOL EXTENSION(จ๏, ࠾༻ଆ) class ViewController: UIViewController { @IBAction func
dismissAction(_ sender: UIButton) { dismiss(vc: self) } } extension ViewController: DismissDelegate {} ֦ுͨ͠ProtocolΛ࠾༻ͤ͞Δ͕࣮Λॻ͘ඞཁ͕ແ͍ʂʂ DismissDelegateͷextensionͷ࣮͕ݺΕΔ