Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
ReactiveCococaのMVVMで綺麗なコードができるのか.pdf
Search
Tomohisa Takaoka
June 27, 2014
Technology
3.5k
4
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
ReactiveCococaのMVVMで綺麗なコードができるのか.pdf
Tomohisa Takaoka
June 27, 2014
Transcript
34 slides
ReactiveCococaͷMVVMͰ៉ ྷͳίʔυ͕Ͱ͖Δͷ͔ @tomohisa Tomohisa Takaoka 2014/6/27
None
डୗ։ൃ ʴ ΤϯλʔϓϥΠζ J-Tech Creations, Inc www.jtechs.com follow me @tomohisa
ຊͷεϖγϟϧίϯςϯπ Twitter @tomohisa ͔ΒͲ͏ͧ follow me @tomohisa
iOSΞϓϦͷ։ൃख๏ MVCύλʔϯ
•View - xib, Storyboard •Controller - UIViewController •Model (ಠࣗʹ࡞͢Δ) https://developer.apple.com/jp/devcenter/ios/library/japanese.html
͜ͷυΩϡϝϯτ͕ྑ͍ײ͡ͰMVCΛઆ໌͍ͯ͠·͢
ViewController͕େ͖͘ͳΓ͗͢Δʂ ※OSXʹɺCocoaόΠϯσΟϯάͱ͍͏ ViewͱσʔλΛ݁߹ͤ͞Δػೳ͕͋Δ͕ɺ iOSʹଘࡏ͠ͳ͍
ࣾ༻ͷλΠϜγʔτཧΞϓϦ
Background : parse.com ϢʔβʔཧͳͲͬͯ͘ΕΔ
ViewControllerʹσʔλऔಘͷίʔυ͕ͪ͝Ό·ͥ vVC (ංେԽͨ͠Ϗϡʔίϯτϩʔϥʔ)ʹͳͬͯ͠·ͬͨ
ReactiveCocoa Λͬͯ MVVM ʹॻ͖͑Δ
ReactiveCocoaͱʁ Function Reactive Programming (FRP) ΛObjective-CͰ࣮ݱ͢ΔͨΊͷϑϨʔϜϫʔΫ https://github.com/ReactiveCocoa/ReactiveCocoa
http://maoe.hatenadiary.jp/entry/20100109/1263059731
MVVMͱ http://www.teehanlax.com/blog/model-view-viewmodel-for-ios/
MVC MVVM ViewControllerɺେ͖ͳҙຯͰͷ VʹؚΉ
M V VM Model ViewController + IB ViewModel
M V VM Model 1.
Ϟσϧͷํ๏ View, ViewModel͔Β͢Δ
Ϟσϧͷํ๏̍ σʔλ(JSONͳͲͰදݱ͞ΕΔΦϒδΣΫτ) ֤σʔλΛද͢ΫϥεΛ࡞Δ JSON, XML, ParseObject ͳͲͷ DictionaryΞΫηεΛແ͘͢ ͪΌΜͱܕΛ࡞Δ σʔλʹ༝དྷ͢ΔϩδοΫ͜͜ʹॻ͘
ʢྫ͑̎ͷڑΛٻΊͨΓɺΦϒδΣΫτͰܭࢉ͠ ͨΓ͢Δ͍͋ʣ
worktime[“startedTime”] = [NSDate date]; worktime.startedTime = [NSDate date]; × ◦
Ϟσϧͷํ๏̎ σʔλͷಡΈॻ͖ͳͲڞ௨Ͱ͑Δػೳ (Downloader, Uploader, Calculator, Aggregator) ! σʔλͷશମ͔ΒΞϓϦͰूܭ͍ͨ͠ͳͲ μϯϩʔυ͢ΔػೳͳͲ ※parse
sdkʹඞཁͳػೳ͕͋ͬͨͷͰࠓճ࡞ͤͣ
Ϟσϧͷํ๏̏ ΞϓϦʹ݁߹͢Δͷ (ઃఆϑΝΠϧɺConstͳͲ) AppDelegateʹmodelϑΝΠϧΛ࣋ͨͤΔ AppDelegateʹͪ͝Όͪ͝Ό͔͔ͳ͍ʂ ΞϓϦͱͯ͠อ͍࣋ͯ͠Δσʔλ
͏ͱ͖ એݴ ΞϓϦʹ݁߹͢ΔmodelΛ࡞͢Δ
M V VM View Model 2.
https://github.com/ReactiveCocoa/ReactiveViewModel
None
RACCommand: ଞͷΦϒδΣΫτ͔Β࣮ߦग़དྷΔɻ ඇಉظॲཧͷ௨Λड͚Δ͜ͱՄೳ RACSignal: ௨ͷγάφϧΛड͚Δ͜ͱ͕Ͱ͖Δ KVOͰड͚औͬͨΒΓɺ௨ͷޙʹ͞Β ʹ࣍ͷ࡞ۀΛఆٛ͢Δ͜ͱՄೳ
M V VM View and ViewController 3.
ViewModelΛ࡞ͯ͠ɺViewModelͱViewΛόΠϯυ͢Δ
ϘλϯԡԼͷΠϕϯτΛViewModel ͷRACCommandͱؔ࿈͚Δ
ςΩετೖྗ࣌ʹViewModelͷσʔλΛߋ৽ ViewModelͰNoteͷߋ৽Λࢹ͠ɺߋ৽Λֻ͚Δ
ྑ͔ͬͨ •ViewModelʹUIίʔυ͕ͳ͍ͨΊɺUnitTest͕Մೳ •ViewModelʹStatusͳͲΛ࣋ͨͤɺදࣔΛௐ͢Δͷ͕ ༰қͦ͏ •ͦΕͧΕͷίʔυ͕͍ͯ͠ΔͷͰ͔Γ͍͢ •σʔλͷνΣοΫͳͲΛΈࠐΊΔ •εϨουͷཧͳͲ͕ߦΘΕ͍ͯΔͨΊɺόοΫάϥ ϯυͰUI͕มߋ͞ΕΔͳͲͷ͕͋·Γग़ͳͦ͞ ͏
Cons - ѱ͍ •ΊΜͲ͍͘͞ •Θ͔Γʹ͍͘ •ObjCͷػೳΛશ໘తʹ͍ͬͯΔͷͰɺSwift͚ͩͰͲ Ε͚ͩग़དྷΔͷ͔ʁ •ReactiveCocoaΛೖΕΔͱϓϩδΣΫτ͕ॏ͘ͳΔϏϧ υʹͨΒ͕͔͔࣌ؒΔ •ॳΊ͚ͯͩͲ·͔ͩΒͳ͍ڍಈ͕͋Δ
ɹʢ͔Δਓ͍ͨΒڭ͍͑ͯͩ͘͞ʣ
૯ׅɿ େنʹͳΕɺྑ͍ͷ͕ͭ͘Εͦ͏ɻ डୗ͕͍࣌͠ʹϓϩδΣΫτΛखͬ ͯͩ͘͞ΔϑϦʔϥϯε͞Μืूதʂ
More Decks by Tomohisa Takaoka
See All by Tomohisa Takaoka
変わらないものが、変わるものを決める — 意図駆動開発 × イベントソーシング × イミュータブル | What Doesn't Change Decides What Can — IDD × Event Sourcing × Immutability
tomohisa
0
2.1k
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
1.8k
AIコーディングの理想と現実 2026 | AI Coding: Expectations vs. Reality 2026
tomohisa
0
1.7k
Sekibanのコアを5言語で動かす ― イベントソーシング×WASMでやってみた | Running Sekiban's Core in 5 Languages — Event Sourcing × WASM
tomohisa
0
170
Sekiban + Microsoft Orleans のアクターをAWS対応しました / Sekiban + Microsoft Orleans actors are now supported on AWS.
tomohisa
0
230
純粋なイミュータブルモデルを設計してからイベントソーシングと組み合わせるDeciderの実践方法の紹介 /Introducing Decider Pattern with Event Sourcing
tomohisa
1
3.1k
.NET Conf 2025 の興味のあるセッ ションを復習した / dotnet conf 2025 quick recap for backend engineer
tomohisa
0
220
dnx で実行できるコマンド、作ってみました
tomohisa
0
330
AIと協働し、イベントソーシングとアクターモデルで作る後悔しないアーキテクチャ Regret-Free Architecture with AI, Event Sourcing, and Actors
tomohisa
8
44k
Other Decks in Technology
See All in Technology
HTTP通信に使おうとすると実はめんどくさいfile_get_contents
maguroalternative
0
260
認知の質も文化醸成も。数年取り組んで見えてきた技術広報のKPI設計 / Tech PR KPIs: Lessons on Awareness Quality and Culture After Several Years
bitkey
PRO
0
220
AWS Client VPNの設定でハマったポイントとその過程での気づき
amarelo_n24
1
440
AWS Well-Arhitected Frameworkセキュリティの柱 について
miu_crescent
PRO
2
260
こんなに変わった! AWSネットワークの常識
shotashiratori
16
11k
お風呂場をサーバルームにしよう
yusuke427
0
400
クラウドでも使えるNetApp -現場目線での設計とクラウドバックアップの活用
ryutakondo
1
330
[関西Kaggler会 20261113] 続・コミュニティコンペのススメ
nejumi
0
200
セキュリティチームは どのコンテナイメージの脆弱性対応を優先すべきか 〜CISA新指針とSCCで作る脆弱性トリアージ〜
swdtkuy
0
330
現地速報! Microsoft Ignite アップデートレポート
kasada
1
460
From vibe coding to reliable (agentic) development
jcabot
0
250
Is the Website Dying?
miriamschwab
0
160
Featured
See All Featured
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
1
320
We Are The Robots
honzajavorek
0
460
Darren the Foodie - Storyboard
khoart
PRO
5
4.1k
BBQ
matthewcrist
90
10k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.5k
Un-Boring Meetings
codingconduct
0
510
From π to Pie charts
rasagy
1
460
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k
Test your architecture with Archunit
thirion
2
2.5k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.4k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
520