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
yuichiro_takahashi
January 29, 2019
Technology
0
74
Mobile Programming Protocol Extension
MobileProgrammingの授業で使うスライドです!
yuichiro_takahashi
January 29, 2019
Tweet
Share
More Decks by yuichiro_takahashi
See All by yuichiro_takahashi
App Clip - in a nutshell
yuichirokato
0
240
巨大な機能を VIPER + MicroViewController でいい感じに実装した話
yuichirokato
1
720
Mobile Programming Protocol
yuichirokato
0
73
Mobile Programming enum
yuichirokato
0
150
Mobile Programming Optional
yuichirokato
0
120
Mobile Programming Struct
yuichirokato
0
120
Mobile Programming Initializer Beta
yuichirokato
0
110
Mobile Programming Inheritance
yuichirokato
0
130
Mobile Programing Property & Method
yuichirokato
0
140
Other Decks in Technology
See All in Technology
プロデザ! BY リクルート vol.18_リクルートのリサーチ実践組織「リサーチブーストコミュニティ」
recruitengineers
PRO
3
260
複雑な構成要素を持つUIとの向き合い方 〜新・支出グラフでの実例〜 / B43 TECH TALK
nakamuuu
0
130
JSON攻略法.pdf
miyakemito
8
4.4k
コンテナセキュリティの基本と脅威への対策
kyohmizu
3
740
KubeCon EU 2024 Recap “Kubernetes Policy Time Machine: Where to Next?”
ryysud
0
180
Postman v10リリース後を振り返る / Looking back at Postman v10 after release
yokawasa
1
150
Cloud Native Java with Spring Boot (CNCF Aarhus, April 2024)
thomasvitale
1
150
**強い**エンジニアのなり方 - フィードバックサイクルを勝ち取る / grow one day each day
soudai
64
19k
The CloudCompare project by Dr. Daniel Girardeau-Montaut
kentaitakura
0
520
MySQL の SQL クエリチューニングの要所を掴む勉強会
andpad
2
5k
プロトタイピングによる不確実性の低減 / Reducing Uncertainty through Prototyping
ohbarye
5
370
AOAI をきっかけに 社内の Azure 管理を見直した話
recruitengineers
PRO
1
180
Featured
See All Featured
Designing with Data
zakiwarfel
95
4.8k
KATA
mclloyd
14
12k
Art, The Web, and Tiny UX
lynnandtonic
288
19k
Documentation Writing (for coders)
carmenintech
59
3.9k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
226
51k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
1
1.3k
Side Projects
sachag
451
41k
Designing for humans not robots
tammielis
248
25k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
186
16k
[RailsConf 2023] Rails as a piece of cake
palkan
22
3.9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
658
120k
How to Ace a Technical Interview
jacobian
272
22k
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ͷ࣮͕ݺΕΔ