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
iOS App デザインパターン 基礎編
Search
Yusuke Ito
February 20, 2012
Programming
15
4.1k
iOS App デザインパターン 基礎編
Yusuke Ito
February 20, 2012
Tweet
Share
More Decks by Yusuke Ito
See All by Yusuke Ito
Macとオーディオ再生 2024/11/02
yusukeito
0
310
おうちHackを取り入れた リノベーション事例
yusukeito
0
630
Server Side Swiftを しばらく運用してみた話
yusukeito
0
550
Swift からword2vecを 使ってみる
yusukeito
0
1k
Swift Outside the Box
yusukeito
1
2.4k
SwiftでgRPCとProtocolBuffersを使う
yusukeito
4
1.3k
Swift on Raspberry Pi でI2Cデバイスを使う
yusukeito
1
640
Isomorphic Swift
yusukeito
2
580
Swiftの値付きEnumをHackする
yusukeito
0
290
Other Decks in Programming
See All in Programming
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
200
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.3k
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
17
4.3k
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
180
Java ジェネリクス入門 2024
nagise
0
680
レガシーシステムにどう立ち向かうか 複雑さと理想と現実/vs-legacy
suzukihoge
14
2k
C++でシェーダを書く
fadis
6
3.8k
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.3k
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
250
受け取る人から提供する人になるということ
little_rubyist
0
170
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
300
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
290
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
64k
RailsConf 2023
tenderlove
29
890
Agile that works and the tools we love
rasmusluckow
327
21k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.3k
Measuring & Analyzing Core Web Vitals
bluesmoon
2
70
Designing the Hi-DPI Web
ddemaree
280
34k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.8k
Unsuck your backbone
ammeep
668
57k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Into the Great Unknown - MozCon
thekraken
32
1.5k
10 Git Anti Patterns You Should be Aware of
lemiorhan
654
59k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
Transcript
iOS App σβΠϯύλʔϯ #1 Yusuke Ito
http://www.flickr.com/photos/naotakem/4570128498 σβΠϯύλʔϯͷॏཁੑ
σβΠϯύλʔϯͷॏཁੑ ϑϨΩγϒϧɾָʹมߋՄೳ Ϧʔϯ(ΞδϟΠϧ)։ൃָ͕ʹ ίʔυͷՄಡੑͷ্ εύήοςΟԽͷࢭ ύϑΥʔϚϯεͷ্ɾϝϞϦϦʔΫͷࢭ ...͕ظͰ͖Δ
iOS AppͷΞʔΩςΫνϟ Model-View-Controller(MVC)Λ౿ऻ Rails(Ruby)ͷαʔόαΠυWebΞϓϦͱશ͘ҧ͏ (WebΞϓϦ→iOSҠߦͷਓҙ) Կ͕Ұ൪͍͔ۙ→NextSTEP ͦΜͳΜΔ͔!! iOSͷจԽΛΔඞཁ͕͋Δɻ MVCվΊModel-View-ViewController
ͦͷલʹMVCͱ Model View Controller ߋ৽ ߋ৽ มߋ ίϯτϩʔϥ͕શମͷϑϩʔΛ੍ޚ มߋ
iOS, UIKitͰ... Model View Controller UIViewController, UINavigationController... NSString, NSDictionary, NSArray...
UIView, UITableView...
Bad pattern #1 Model Controller View View View View Controller
Controller Controller View View View Model Model Model Model Model
Bad pattern #2 View View View View View View View
Model Model Model Model Model Model Controller View View
Better pattern Model Controller View Model Controller View Model Controller
View
UIKitجຊύλʔϯ ௨(NSNotificationCenter) σϦήʔτ(NSTableViewDelegateͳͲ) λʔήοτɾΞΫγϣϯ(UIControlͳͲ, -addTarget:) Ωʔࢹ(Key-Value-Observing) ※ͯ͢Objective-Cͷݴޠ༷Ͱͳ͘ɺ ύλʔϯͷҰछ KVOඍົ͚ͩͲ...
Case Study อ͔࣋Βߟ͑Δ ΦϒδΣΫτ͕ΦϒδΣΫτΛอ࣋͢Δ/͠ͳ͍ ͱ͍͏͜ͱ(ʹࢀরΛ࣋ͭ, Reference) ʹ͍ͭͯϧʔϧΛ࡞Δ ඞવతʹσβΠϯύλʔϯ͕ཁΔɾߟ͑Δ ϧʔϧΛ࡞ΕͦͷϧʔϧΛલఏʹͤ͟ΔΛಘͳ͍ ϧʔϧʹσβΠϯύλʔϯͰ͍͍
࠶ͼModel-View-ViewController Model: NSObject͔Β࡞Δ, NSDictionary, NSArray... View: UIViewͷαϒΫϥεͯ͢(UITableView, UIButton, UIScrollView...) ViewController:
UIViewController, UINavigationViewController, UITabViewController...
Model-View-ViewController ͦΕͧΕ͕͖࣋ͭͷ͖࣋ͭ Ͱͳ͍ͷ ҹ=อ࣋(ࢀর)
Model Controller View × × Model͔Βݟͯ... View࣋ͨͳ͍ ViewController࣋ͨͳ͍
ViewController࣋ͨͳ͍ Modelجຊ࣋ͨͳ͍ Viewʹදࣔ͢Δඞཁ͕͋Δ ͷ͚ͩ࣋ͭ Model Controller View × × View͔Βݟͯ...
ViewΛ࣋ͭ ModelΛ࣋ͭ Model Controller View ViewController͔Βݟͯ...
Model Controller View ࠶ͼ: อ͔࣋Βߟ͑Δ ·ͱΊ
Model Controller View Ͳ͏ͬͯࢀরͷແ͍ΦϒδΣΫτಉ࢜ ͷϝιουΛݺͼग़͔͢ σϦήʔτ Target-Action ௨ KVO ϝιου
(ϝοηʔδૹ৴)
σϦήʔτͷॻ͖͔ͨ ࠶ͼ: σϦήʔτύλʔϯ delegateͱ͍͏໊લΛΑ͘͏ dataSourceσϦήʔτͷύλʔϯ UITableViewUIScrollViewͷॻ͖͔ͨΛࢀߟʹ͢Δ
Target-Actionͷॻ͖͔ͨ ࠶ͼ: ͜Εύλʔϯ UIResponderΛܧঝ(Responder-Chainύλʔϯ) UIViewUIViewControllerUIResponderΛܧঝ ૹΔଆ(View): UIButton(<=UIControl) - addTarget:action:forControlEvents: TargetΛnilʹ͢Δ
ड͚ͱΔଆ(Controller): ↑Ͱ࣮ͨ͠actionͷϝιουΛ࣮͢Δ - (void)someAction:(id)sender
σβΠϯύλʔϯͷशಘ ʹจষͱಉ͡ ಡΉ: ࣗͷίʔυɾGithub(ଞਓ)ͷίʔυɾࣗͷ աڈͷίʔυ ॻ͘: ίʔσΟϯάɾϦϑΝΫλϦϯάɾ৭ʑͳύ λʔϯΛࢼ͢
͓͢͢Ίใݯ Apple ެࣜυΩϡϝϯτ WWDC2010-2011 ϏσΦͱεϥΠυ Dynamic Objective-C / Լ
/ ຊ iOS։ൃʹ͓͚ΔύλʔϯʹΑΔΦʔτϚςΟζϜ / Լ / ຊ
εϥΠυ http://bit.ly/xZ7NsF ίʔσΟϯάΨΠυϥΠϯͷ http://yusukeito.me/post/16447745113 https://github.com/novi Thank You ‼