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
実践Protocol-Extension
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Shinji Kobayashi
October 06, 2016
Programming
77
0
Share
実践Protocol-Extension
Shinji Kobayashi
October 06, 2016
More Decks by Shinji Kobayashi
See All by Shinji Kobayashi
5分でできる UITableViewのDrag & Drop
gentlesoft
0
470
自社コンテンツ配信 のためのWebView Tips
gentlesoft
2
5.6k
UIKitDynamicsの活用法
gentlesoft
0
610
iOS9のUIKitDynamics
gentlesoft
0
50
SwiftでUIKitDynamics
gentlesoft
0
57
CoreDataによるデータ駆動型プログラミング
gentlesoft
0
200
Other Decks in Programming
See All in Programming
AIベース静的検査器の偽陽性率を抑える工夫3選
orgachem
PRO
4
430
JAWS-UG横浜 #100 祝・第100回スペシャルAWS は VPC レスの時代へ
maroon1st
0
210
when storing skills in S3 file
watany
3
1.1k
PicoRuby for IoT: Connecting to the Cloud with MQTT
yuuu
2
750
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
Making the RBS Parser Faster
soutaro
0
660
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
480
書籍「ユーザーストーリーマッピング」が私のバイブル
asumikam
4
470
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
170
検索設計から 推論設計への重心移動と Recall-First Retrieval
po3rin
5
1.5k
ローカルLLMでどこまでコードが書けるか / How much code can be written on a local LLM
kishida
2
290
PHPでバイナリをパースして理解するASN.1
muno92
PRO
0
410
Featured
See All Featured
First, design no harm
axbom
PRO
2
1.2k
GraphQLとの向き合い方2022年版
quramy
50
15k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.8k
Design in an AI World
tapps
1
210
Designing for humans not robots
tammielis
254
26k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
500
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
180
Ruling the World: When Life Gets Gamed
codingconduct
0
220
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
280
RailsConf 2023
tenderlove
30
1.4k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.2k
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
Transcript
࣮ફProtocol-Extension Shinji Kobayashi TOPLOG / Gentlesoft shibuya.swift #5
Swift3.0ରԠ ਐΜͰ·͔͢ʁ
ࢲ·ͩख͔ͣͰ͢ɻ (2.3ରԠ͕Α͏͘ऴΘͬͨͱ͜ΖͰ͢)
ͳͥ͜Ε΄ͲͷखؒΛ ͔͚ͯSwiftΛ͏ͷ͔ʁ •Objective-CΑΓ؆ܿʹॻ͚Δ͔Βʁ • ؔܕͷαϙʔτʁ •දݱྗͷߴ͍enumʁ •Protocol-Extensionʂ
Protocol-Extension ͷԿ͕͍͍ʁ
ϓϩάϥϜͷ࣮ํ๏ ΛมԽͤͨ͞
Ͳ͏͍͏෩ʹʁ
֮͑ͯཉ͍͠ศརػೳ •associatedtype •where Self: Hogehoge •Selfܕ
NameɿShinji Kobayashi Twitterɿ@gentlejkov GentleSoft Who are you? http://gentlesoft.net
Work https://toplog.co.jp/ TOPLOG iOS Engineer
TOPLOG APP 2016/3/1 ver.1.0.0 Now ver.2.1.3 100% pure Objective-C 70%
Swift
TOPLOG APP ΩϡϨʔγϣϯ ΦϦδφϧهࣄ
TOPLOG APP ΦϦδφϧهࣄ දࣔ͢Δσʔλҧ͏͕ػೳࣅ͍ͯΔ ΩϡϨʔγϣϯ
TOPLOG APP ΩϡϨʔγϣϯ ΦϦδφϧهࣄදࣔ ࠂදࣔ ΦϦδφϧهࣄ
TOPLOG APP ΩϡϨʔγϣϯ ΦϦδφϧهࣄදࣔProtocol ࠂදࣔProtocol ΦϦδφϧهࣄ
RANKING MY CLIP TOPLOG APIͷΓཁૉ͕एׯҧ͏(ߏಉ͡) Ϧετͷ࣮ํ๏ಉ͡ʢαʔόଆͰΓସ͑ʣ ΦϦδφϧهࣄදࣔ
ΦϦδφϧهࣄදࣔ
ΦϦδφϧهࣄදࣔ APIͷΓͷڞ௨෦ΛProtocolͰఆٛ͠ associatedtypeͰઃఆͨ͠ܕContentsΛ੍͢Δ ContentsܕͷσʔλΛ࣋ͭΫϥεͱͯ͠ ৼΔ͏͜ͱ͕Ͱ͖Δ
ΦϦδφϧهࣄදࣔ Extension
ΦϦδφϧهࣄදࣔ Extension ΦϦδφϧهࣄΛදࣔ͢ΔͨΊͷ ϏδωεϩδοΫΛ·ͱΊͨͷ
ࠂදࣔ Protocol-Extension ࠂΛදࣔ͢ΔͨΊͷ ϏδωεϩδοΫΛ·ͱΊͨͷ
ͭ·Γ Protocol-Extension
ϏδωεϩδοΫΛ ViewController͔Β ࣗવʹΓग़ͤΔ
ExtensionΛUIViewControllerͱͯ͠ѻ͍͍ͨ લड़ͨ͠Protocolݪଇ UIViewControllerͰ࣮͞ΕΔ Extensionͷܕ੍
Extensionͷܕ੍
ExtensionΛUIViewControllerͰ੍ ͜ͷExtensionͰ selfUIViewControllerͱͯ͠ѻ͑Δ Extensionͷܕ੍
ΦϦδφϧهࣄදࣔProtocolͱࠂදࣔProtocol ͷ྆ํΛ࣮͢ΔViewController͕͋Δ ্هProtocolͷ྆ํΛ࣮͢Δ߹ Ұ෦ϩδοΫΛมߋ͍ͨ͠ Extensionͷܕ੍
ඪ४࣮ ಛघ࣮ Extensionͷܕ੍
ඪ४࣮ ಛघ࣮ ಛఆͷProtocolΛ࣮͍ͯ͠Δ࣌ͷ ผϩδοΫ Extensionͷܕ੍
ܕ੍ʹΑΔಛघ࣮ ͷҙ ProtocolʹએݴΛ͓͔ͯ͠ͳ͍ͱ ϙϦϞϑΟοΫʹಈ࡞͠ͳ͍
Selfܕ Protocolʹ͓͍ͯࣗࣗΛࢦ͢ ܕͷ͜ͱ ࣗࣗͷΦϒδΣΫτΛฦ͢ ExtensionͷϝιουΛ࣮Ͱ͖Δ
ڞ௨ͷFactoryϝιου
֮͑ͯཉ͍͠ศརػೳ ϓϩάϥϜΛࣗવʹ ܕ҆શʹ͢ػೳ •associatedtype •where Self: Hogehoge •Selfܕ
·ͱΊ •Protocol-ExtensionΛ͏ࣄͰɺϏδωεϩδοΫ ΛࣗવʹViewController͔ΒΓग़͠ɺඞཁʹԠ ֤ͯ͡ΫϥεʹదԠͤ͞Δࣄ͕Մೳͱͳͬͨ •assosiatedtype, where, SelfܕͳͲͷػೳʹΑΓܕ҆ શͰ෭࡞༻ͷগͳ͍ϩδοΫͷڞ௨Խ͕Ͱ͖Δ