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
Macとオーディオ再生 2024/11/02
yusukeito
0
150
おうちHackを取り入れた リノベーション事例
yusukeito
0
620
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
Kubernetes for Data Engineers: Building Scalable, Reliable Data Pipelines
sucitw
1
190
GCCのプラグインを作る / I Made a GCC Plugin
shouth
1
150
Amazon Neptuneで始めてみるグラフDB-OpenSearchによるグラフの全文検索-
satoshi256kbyte
4
320
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
420
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.1k
From Subtype Polymorphism To Typeclass-based Ad hoc Polymorphism- An Example
philipschwarz
PRO
0
170
offers_20241022_imakiire.pdf
imakurusu
2
360
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
0
150
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
530
のびしろを広げる巻き込まれ力:偶然を活かすキャリアの作り方/oso2024
takahashiikki
1
410
Go言語でターミナルフレンドリーなAIコマンド、afaを作った/fukuokago20_afa
monochromegane
2
140
WEBエンジニア向けAI活用入門
sutetotanuki
0
300
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
425
64k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
43
6.6k
Speed Design
sergeychernyshev
24
570
Optimizing for Happiness
mojombo
376
69k
A Philosophy of Restraint
colly
203
16k
Rails Girls Zürich Keynote
gr2m
93
13k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
290
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Imperfection Machines: The Place of Print at Facebook
scottboms
264
13k
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