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
1.1k
クライアント型iOSアプリのつくりかた
Yusuke Ito
May 25, 2013
Tweet
Share
More Decks by Yusuke Ito
See All by Yusuke Ito
Macとオーディオ再生 2024/11/02
yusukeito
0
520
おうちHackを取り入れた リノベーション事例
yusukeito
0
650
Server Side Swiftを しばらく運用してみた話
yusukeito
0
560
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
650
Isomorphic Swift
yusukeito
2
590
Swiftの値付きEnumをHackする
yusukeito
0
300
Other Decks in Programming
See All in Programming
急成長期の品質とスピードを両立するフロントエンド技術基盤
soarteclab
0
930
testcontainers のススメ
sgash708
1
120
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
menu基盤チームによるGoogle Cloudの活用事例~Application Integration, Cloud Tasks編~
yoshifumi_ishikura
0
110
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
120
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
260
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
DevFest Tokyo 2025 - Flutter のアプリアーキテクチャ現在地点
wasabeef
5
900
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
190
From Translations to Multi Dimension Entities
alexanderschranz
2
130
Effective Signals in Angular 19+: Rules and Helpers
manfredsteyer
PRO
0
100
Featured
See All Featured
Dealing with People You Can't Stand - Big Design 2015
cassininazir
365
25k
YesSQL, Process and Tooling at Scale
rocio
169
14k
Faster Mobile Websites
deanohume
305
30k
A designer walks into a library…
pauljervisheath
204
24k
Become a Pro
speakerdeck
PRO
26
5k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
How GitHub (no longer) Works
holman
311
140k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
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