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
78
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
330
巨大な機能を VIPER + MicroViewController でいい感じに実装した話
yuichirokato
1
790
Mobile Programming Protocol
yuichirokato
0
82
Mobile Programming enum
yuichirokato
0
160
Mobile Programming Optional
yuichirokato
0
130
Mobile Programming Struct
yuichirokato
0
120
Mobile Programming Initializer Beta
yuichirokato
0
120
Mobile Programming Inheritance
yuichirokato
0
140
Mobile Programing Property & Method
yuichirokato
0
160
Other Decks in Technology
See All in Technology
20250307_エンジニアじゃないけどAzureはじめてみた
ponponmikankan
2
280
スクラムというコンフォートゾーンから抜け出そう!プロジェクト全体に目を向けるインセプションデッキ / Inception Deck for seeing the whole project
takaking22
4
360
開発者のための FinOps/FinOps for Engineers
oracle4engineer
PRO
2
300
目標と時間軸 〜ベイビーステップでケイパビリティを高めよう〜
kakehashi
PRO
8
1.1k
最近のラズピッピいじり / 20250308-rpijam-13th-birthday
akkiesoft
0
150
Aurora PostgreSQLがCloudWatch Logsに 出力するログの課金を削減してみる #jawsdays2025
non97
1
280
Amazon Athenaから利用時のGlueのIcebergテーブルのメンテナンスについて
nayuts
0
150
失敗しないAIエージェント開発:階層的タスク分解の実践
kworkdev
PRO
0
600
AI-Driven-Development-20250310
yuhattor
3
330
[OpsJAWS Meetup33 AIOps] Amazon Bedrockガードレールで守る安全なAI運用
akiratameto
1
150
サイト信頼性エンジニアリングとAmazon Web Services / SRE and AWS
ymotongpoo
8
2k
OSSの実装を参考にBedrockエージェントを作る
moritalous
2
380
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
How STYLIGHT went responsive
nonsquared
99
5.4k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Automating Front-end Workflow
addyosmani
1369
200k
Fireside Chat
paigeccino
36
3.2k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
[RailsConf 2023] Rails as a piece of cake
palkan
53
5.3k
Gamification - CAS2011
davidbonilla
80
5.2k
Why Our Code Smells
bkeepers
PRO
336
57k
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ͷ࣮͕ݺΕΔ