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アプリのつくりかた
Search
Yusuke Ito
May 25, 2013
Programming
4
1k
クライアント型iOSアプリのつくりかた
Yusuke Ito
May 25, 2013
Tweet
Share
More Decks by Yusuke Ito
See All by Yusuke Ito
おうちHackを取り入れた リノベーション事例
yusukeito
0
610
Server Side Swiftを しばらく運用してみた話
yusukeito
0
540
Swift からword2vecを 使ってみる
yusukeito
0
990
Swift Outside the Box
yusukeito
1
2.3k
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
280
Swift プロトコル指向なCのラッパーを作る
yusukeito
3
1.3k
Other Decks in Programming
See All in Programming
5年分のツケを一気に払った話
soogie
3
960
Pythonによるイベントソーシングへの挑戦と現状に対する考察 / Challenging Event Sourcing with Python and Reflections on the Current State
nrslib
3
840
Assembling the Future: crafting the missing pieces of the Ruby on Wasm puzzle
skryukov
0
120
個人開発のおいしさと続け方
3l4l5
1
260
RemixとCloudflare Stack におけるFile Upload
ossamoon
1
120
Micro Frontends Unmasked: Opportunities, Challenges, Alternatives
manfredsteyer
PRO
0
250
MLOps in Mercari Group’s Trust and Safety ML Team
cjhj
1
100
全方位強化 Python 服務可觀測性:以 FastAPI 和 Grafana Stack 為例
blueswen
1
360
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
1.1k
Modern Functional Fluent CFML REST by Luis Majano
ortus24
0
110
What is TDD?
urakawa_jinsei
1
200
Frontend Magic mit CSS Houdini
joergneumann
0
420
Featured
See All Featured
Product Roadmaps are Hard
iamctodd
PRO
48
10k
It's Worth the Effort
3n
182
27k
Scaling GitHub
holman
458
140k
Building a Scalable Design System with Sketch
lauravandoore
458
32k
RailsConf 2023
tenderlove
28
830
Why Our Code Smells
bkeepers
PRO
334
57k
Learning to Love Humans: Emotional Interface Design
aarron
271
40k
Become a Pro
speakerdeck
PRO
23
4.9k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
Pencils Down: Stop Designing & Start Developing
hursman
119
11k
Writing Fast Ruby
sferik
624
60k
What’s in a name? Adding method to the madness
productmarketing
PRO
22
3.1k
Transcript
ΫϥΠΞϯτܕiOSΞϓϦ ͷͭ͘Γ͔ͨ Yusuke Ito, @novi_, Github: novi at ୈ4ճ iphone_dev_jp
౦ژiPhone/Macษڧձ
About me http://about.me/yusukeito @novi_, Github: novi ߴઐଔۀޙϑϦʔ WebͷελʔτΞοϓ͍͔ͭ͘ UI, UX
ͱ Cocoa(iOS)ͱMac 7͘Β͍
Agenda ࣮ྫ(Githubͷίʔυ) MVCͱσβΠϯύλʔϯ ։ൃϓϩηε
త খ͍͞νʔϜ(2,3ਓ)Ͱ ৽نiOSΞϓϦΛ ޮྑ͘ɺ҆શʹɺ͘ ͭ͘Δ͜ͱΛతͱ͢Δɻ (৽نࣄۀελʔτΞοϓΛλʔήοτ)
࣮ྫͱͻͳܗ LTAPIRequest Google it or https://github.com/novi/LTAPIRequest ࣮ίʔυࢀর iOS(Cocoa)ͷMVCʹ͍ͭͯษڧ͢ΔͨΊ ϑϨʔϜϫʔΫΛΘͳ͍߹ͷ࣮ྫΛఏڙ͢Δ ͨΊ
(σβΠϯ)ύλʔϯ ܦݧଇ͔ΒಘΒΕͨ͏·͍͘͘ͱࢥΘΕΔߟ͑ํͱ ࣮ ਖ਼ղෆਖ਼ղແ͍ Ϋϥεͷઃܭํ๏ɺΦϒδΣΫτͷࢀরؔͷ ࣋ͨͤํɺΛͯ͠ޮྑ͘ɺಡΈ͘͢ɺ͢Δ
ϑϨʔϜϫʔΫͱϥΠϒϥϦ ϥΠϒϥϦϑϨʔϜϫʔΫΫϥε(.m)ͷू·Γ ϑϨʔϜϫʔΫ࣮(.m)ʹՃ͑ͯઃܭσβΠϯύ λʔϯͷҙຯ߹͍͕ՃΘΔ e.g.) UIKit=ϑϨʔϜϫʔΫ=MVC͕͋Δ ϑϨʔϜϫʔΫͷϧʔϧʹैͬͯΞϓϦΛ࡞Δ e.g.) -layoutSubviews ͕ݺΕͨΒxx͢Δ
http://www.flickr.com/photos/naotakem/4570128498 σβΠϯύλʔϯͷॏཁੑ
σβΠϯύλʔϯͷత ͍͑͢ίʔυΛॻ͘ʹಡΈ͍͢ Έ͍͑͢ίʔυΛॻ͘ ఔΑ݁͘߹͞Ε͍ͯΔ(ີͰૈͰͳ͍தؒ) ϦϑΝΫλϦϯά͍͢͠ ςετ͍͢͠ मਖ਼͍͢͠ ॻ͘ͷʹख͕͔͔ؒΒͳ͍
iOS MVC Webͱҧͬͯεςʔτϑϧ(not εςʔτϨε) Model-View-ViewController (MVC)
MVCͱ Model View View Controller ߋ৽ ߋ৽ มߋ ίϯτϩʔϥ͕શମͷϑϩʔΛ੍ޚ มߋ
iOS, UIKitͰ... Model View Controller UIViewController, UINavigationController... NSString, NSDictionary, NSArray...
UIView, UITableView...
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 ͦΕͧΕ͕͖࣋ͭͷ͖࣋ͭ Ͱͳ͍ͷ ҹ=อ࣋(ࢀর)
ViewΛ࣋ͭ ModelΛ࣋ͭ Model Controller View ViewController͔Βݟͯ...
Model Controller View × × Model͔Βݟͯ... View࣋ͨͳ͍ ViewController࣋ͨͳ͍
ViewController࣋ͨͳ͍ ModelΛ࣋ͭ Model Controller View × View͔Βݟͯ...
Model Controller View ࠶ͼ: อ͔࣋Βߟ͑Δ ·ͱΊ
Model Controller View Ͳ͏ͬͯࢀরͷແ͍ΦϒδΣΫτಉ࢜ ͷϝιουΛݺͼग़͔͢ σϦήʔτ Target-Action ௨ KVO Callback
ϝιου (ϝοηʔδૹ৴)
Case Study2 ViewControllerͷࣄ͔Βߟ͑Δ ViewController͕͢Δ͜ͱɺ͠ͳ͍͜ͱΛϧʔϧԽ͢Δ ඞવతʹσβΠϯύλʔϯ͕ཁΔɾߟ͑Δ ϧʔϧΛ࡞ΕͦͷϧʔϧΛલఏʹͤ͟ΔΛಘͳ͍ ϧʔϧʹσβΠϯύλʔϯͰ͍͍
ViewController͕͢Δ͜ͱ NSNotificationCenter͔Β௨Λड͚औΔ KVOͰ௨Λड͚औΔ ModelΛอ࣋͢Δ ViewʹModelΛ͢(setModelName:DataSourceܦ༝Ͱ) ViewΛੜ(ΠϯελϯεԽ)͢Δ ViewͷΠϕϯτΛड͚औΔ(Target-ActionDelegate͔Β)
ViewController͕͠ͳ͍͜ͱ ωοτϫʔΫ͔ΒσʔλΛऔಘ͢Δ(ϦΫΤετͨ͠ ޙɺ௨σʔλΛड͚औΔ) σΟεΫʹอଘ͢Δ σʔλΛอ࣋͢Δ ೖྗ͞Εͨσʔλͷ͕ਖ਼͍͔͠ݕূ͢Δ (Ҏ্ͯ͢Model͕୲͢Δ)
σϦήʔτͷॻ͖͔ͨ ࠶ͼ: σϦήʔτύλʔϯ delegateͱ͍͏໊લΛΑ͘͏ dataSourceσϦήʔτͷύλʔϯ UITableViewUIScrollViewͷॻ͖͔ͨΛࢀߟʹ͢Δ
Target-Actionͷॻ͖͔ͨ ࠶ͼ: ͜Εύλʔϯ UIResponderΛܧঝ(Responder-Chainύλʔϯ) UIViewUIViewControllerUIResponderΛܧঝ ૹΔଆ(View): UIButton(<=UIControl) - addTarget:action:forControlEvents: TargetΛnilʹ͢Δ
ड͚ͱΔଆ(Controller): ↑Ͱ࣮ͨ͠actionͷϝιουΛ࣮͢Δ - (void)someAction:(id)sender
։ൃϓϩηε తͷͨΊʹiOSΞϓϦͷ։ൃϓϩηεʹ͍ͭͯύλ ʔϯԽͯ͠ΈΔ ։ൃϓϩηεͷύλʔϯ
త খ͍͞νʔϜ(2,3ਓ)Ͱ ৽نiOSΞϓϦΛ ޮྑ͘ɺ҆શʹɺ͘ ͭ͘Δ͜ͱΛతͱ͢Δɻ (৽نࣄۀελʔτΞοϓΛλʔήοτ)
։ൃϓϩηε ՝ ਓؒతͳ੍(ݸੑɺٕೳϨϕϧɺϞνϕʔγϣ ϯɺࣄελΠϧ)ΛͲ͏Γӽ͑Δ͔? աఔͰνʔϜΛҭͯΔ͜ͱ͕Ͱ͖Δ͔ աఔͰจԽΛ࡞Δ͜ͱ͕Ͱ͖Δ͔
୲ ίʔσΟϯά 1 or 2ਓ ྫ͑, Storyboard, ViewControllerͷਓ Model, View,
Utils, Manager, Networkͷਓ Ϟδϡʔϧ͝ͱ͚Δ
։ൃཧ ։ൃϑϩʔΛνʔϜͰཱ֬͢Δ ࿈བྷखஈ νϟοτϫʔΫ etc.... ༻ϑϨʔϜϫʔΫɺϥΠϒϥϦ υΩϡϝϯτIssueཧγεςϜ Google Docs, Github
Issues, Pivotal Tracker, etc...
ϑΟʔυόοΫ UXͷίΞʹͳΔେࣄͳػೳΛ͘࡞Δ த్ʹಈ͔ͳ͍ػೳΛͩΒͩΒ࣮͠ͳ͍ ग़དྷͨΒɺϦϦʔε͢Δ (νʔϜorςελʔ) ػೳΛϨϏϡʔ͢Δ
υΩϡϝϯτ ίʔυͱಉ͡Α͏ʹෛ࠴Ͱ͋Δ υΩϡϝϯτͷ ࡞ऀ͕Ξοϓσʔτ͢ΔΛ࣋ͭ ࡞ऀ͕Λ࣋ͨͳ͘ͳΔ߹յ͢ ΨΠυϥΠϯ·ͨςϯϓϨʔτΛ࡞
UIσβΠϯ ඞͣఆ͞ΕΔ࣮σʔλΛ༻ UX, UI͕ᐆດͳঢ়ଶͰϑϧػೳΛ࣮͠ͳ͍ จݴ࠷ॳ͔ΒͪΌΜͱߟ͑Δ
࣮ͷઃܭ কདྷ࣮͢Δ͔͠Εͳ͍ػೳͷઃܭ͢Δ ͨͩ͠ɺ࠷ॳͷϦϦʔεͰγϯϓϧͳػೳ ʹߜΔ ࣮ࡍʹςετίʔυΛॻ͔͘ʹؔΘΒͣςετ ͢ΔલఏͰઃܭ͢Δ(ςετ͍͢͠ઃܭ) ઌΛݟ͗ͨ͢ઃܭΛ͠ͳ͍ HTTP API, UI...,
Ϋϥε
ίʔσΟϯά ΨΠυϥΠϯΛ࡞ ίʔυϨϏϡʔ pull࣌ʹߦ͏ɺఆظతʹߦ͏(optional) DRY (Don’t Repeat Yourself) ͨͩ͠ҙࣝ͗͢͠ͳ͍ ϞδϡʔϧԽɺΫϥεԽ
όʔδϣϯཧ ϒϥϯνΛΓ͗͢ͳ͍ Storyboard͕ϚʔδͰ͖ͳ͍ 1ਓ͔͠৮Βͳ͍ͳͲ ϏϧυͰ͖ͳ͍ίʔυɺςετ(खorϓϩάϥϜ Ͱ)͍ͯ͠ͳ͍ίʔυίϛοτ͠ͳ͍ ίϛοτϩάͷΨΠυϥΠϯΛ࡞
֎෦ϥΠϒϥϦ ͍͗͢ͳ͍ (Podsศར͚ͩͲ...) 1ػೳ͚͔ͩ͠Θͳ͍ͷʹશ෦ೖΕͳ͚Ε ͳΒͳ͍ͷͳͲ→ସΛ୳͢orࣗͰॻ͘ ෭࡞༻ͷ͋Δͷ༻͠ͳ͍ ϝιουೖΕସ͑Λ͍ͯ͠ΔͷͳͲ ίʔυ͕͑ͳ͍ͷ༻͠ͳ͍
APIϑΝʔετ αʔϏεΛఆٛ (αʔόαΠυͷػೳɾ༷) RESTful API(=υΩϡϝϯτ)Λఆٛ αʔόʔαΠυͷϞοΫΛ࡞Δ(optional) ΫϥΠΞϯταΠυΞϓϦΛॻ͘ RESTful API ͷςετΛॻ͘
αʔόʔαΠυΛ࣮͢Δ
None