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
AWA with Realm
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuji Hato
June 25, 2015
Technology
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AWA with Realm
Yuji Hato
June 25, 2015
More Decks by Yuji Hato
See All by Yuji Hato
ABEMAにおける 生成AI活用の現在地 / The Current Status of Generative AI at ABEMA
dekatotoro
1
1.3k
ABEMAモバイルアプリ開発のDevOps戦略
dekatotoro
1
800
Multiplatform Engineering Roadmap for the Future
dekatotoro
1
190
Introduction to RIBs
dekatotoro
5
1.5k
継続的な開発スタイル 「AbemaTV iOSアプリを週一で リリースしている話」
dekatotoro
6
4.3k
iOS Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
dekatotoro
0
560
動画アプリをなめらかに動かす技術 - iOS -
dekatotoro
0
520
5分で学ぶ差分更新とRxDataSources
dekatotoro
0
390
AbemaTV モバイルアプリの開発体制と 開発プロセスの話
dekatotoro
0
290
Other Decks in Technology
See All in Technology
自律的なチームを作るためにTechPMがやらないこと
ny7760
1
530
Lint の層を組み直した話
bengo4com
3
330
AIエージェントの監視、思考を見るか行動を見るか / Monitoring AI Agents: Thoughts or Actions
yusukeshimizu
2
170
The future of architectural work
ufried
0
190
AWS構成から考えるWebセキュリティ ― WordPressの構築経験から考える公開範囲と更新運用【JAWS FESTA 2026 in AKITA】
cscengineer
PRO
2
360
視野はAIに、視座は人に / ai-for-breadth-humans-for-perspective
nkzn
6
3.2k
AWS Quick 入門 | 目指せ Quick マスター 01
inariku
PRO
1
190
Context Ontology Accelerator 入門 (業務データの意味を、AI エージェントに渡す)
inariku
PRO
3
560
Kiro IDE 入門 (画面の各部から、頼み方、任せ方、戻し方まで) | 目指せ Kiro マスター 02
inariku
PRO
4
140
cdkd (CDK Direct)
gotok365
4
270
Active Directory と Entra ID のむむむな関係
murachiakira
PRO
3
1.7k
AI時代に求められる優秀なTechLeadの振る舞い
pospome
11
15k
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
3.1k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
630
Abbi's Birthday
coloredviolet
4
11k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.7k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.4k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Writing Fast Ruby
sferik
630
63k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
630
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
350
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
800
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
203
77k
Transcript
AWA with Realm (iOS)
ށ ༐ೋ [Yuji Hato] INTRODUCTION ࣗݾհ System Engineerͱͯ͠SIerΛܦͯɺ2011αΠ όʔΤʔδΣϯτʹೖࣾɻ ෳͷAmebaαʔϏεʹͯɺαʔόαΠυ/
Android/iOSΛ୲͠ɺݱࡏAWAͷiOSΤϯδ χΞɻ Engineer 5XJUUFSIUUQTUXJUUFSDPNEFLBUPUPSP (JU)VCIUUQTHJUIVCDPNEFLBUPUPSP
ࠓ Realmʹؔͯ͠ͷ͍ํTips༷ʑͳํ͕ հ͍ͯ͠ΔͷͰɺRealmΛͬͨΞϓϦέʔ γϣϯશମͷઃܭͷհΛ͠·͢
Agenda ɾRealmΛ͏త ɾApplication Architecture ɾͳͥRealm͔ ɾAWAͱ ɾCoding Topics ɾOther Topics
None
༸ָɾָΘͣɺ͍ͭͰͲ͜Ͱ͖ͳָ͚ͩ͠Ή͜ͱ͕Ͱ͖Δ ֹ݄ఆ੍ֹͷԻָετϦʔϛϯάαʔϏε
ͳͥRealm͔
ͳͥ3FBMN͔
ͳͥ3FBMN͔ ɾϞσϧ/ϦϨʔγϣϯ͕ΫϥεఆٛͰΒ͘ ɾύϑΥʔϚϯε͕Α͍ ɾΫϩεϓϥοτϑΥʔϜͰAndroid ɹಉ͡ઃܭ͕Ͱ͖Δ ɾRealmͬͯΔͱ͔ͬ͜Αͦ͞͏ ɾυΩϡϝϯτͷॆ࣮ & αϙʔτ
RealmΛ͏త
3FBMNΛ͏త ɾετϨεϑϦʔͳUI/UXͷ࣮ݱ ɾ௨৴ྔͷݮ ɾදࣔ/ύϑΥʔϚϯεͷ্
Application Architecture
αʔόʔ ΫϥΠΞϯτ ΫϥΠΞϯτͱαʔό ͷσʔλಉظ Application Architecture
αʔόʔ ΫϥΠΞϯτ Dataͷࠩߋ৽/ มߋνΣοΫ Application Architecture ࠩͷΈ
αʔόʔ ΫϥΠΞϯτ ΦϯσϚϯυอଘ Application Architecture ඞཁʹͳͬͨΒ औಘ
Application Design
ͦͷ·͑ʹ… AWAObjective-CͰ࣮͍ͯ͠·͢ ઈࢍSwiftॻ͖͑த ※Bolts-iOSΛ༻͍ͯ͠·͢
Application Design API Server Realm View ViewController Service
Models Modelͷఆٛ
Models @interface EntityHoge : RLMObject @property NSString *hogeId; @property NSString
*name; @property NSInteger updatedAt; @property NSInteger storedAt; // Finders + (EntityHoge *) findById: (NSString *) hogeId; @end @implementation EntityHoge + (NSString *)primaryKey { return @"hogeId"; } + (EntityHoge *) findById:(NSString *)hogeId { RLMRealm *realm = [RealmManager realm]; EntityHoge *hoge = [self objectInRealm:realm forPrimaryKey:hogeId]; return hoge; } @end ModelΫϥεʹFinderͳͲఆ͓ٛͯ͘͠ͱศརɻ
Service RealmObjectΛѻ͏ServiceΛఆٛ
Service @implementation HogeService - (EntityHoge *)read: (NSString *)hogeId { [[RealmManager
realm] refresh]; return [EntityHoge findById:hogeId]; } - (BFTask *)fetch:(NSString *)hogeId withModifiedSince:(NSInteger)modifiedSince { return [[APIClient hogeData:hogeId modifiedSince:modifiedSince] continueWithExecutor: [RealmManager writeExecutor] withSuccessBlock:^id(BFTask *task) { // APIͷΓΛνΣοΫͯࠩ͠ΛRealmʹॻ͖ࠐΈ EntityHoge *hoge = [DataConverter toHoge:task.result]; [RealmManager commit:^(RLMRealm *realm) { [realm addOrUpdateObject:hoge]; }]; }]; } @end ServiceʹreadɺfetchͳͲܾ·ͬͨIFΛ༻ҙ͢Δ͜ͱͰѻ͍͘͢ͳΔɻ ߋ৽࣌Λ͢͜ͱͰAPI͔Βมߋ/ࠩσʔλͷΈΛऔಘͯ͠Realmʹอଘɻ readεϨουΛލ͙͜ͱΛߟྀͯ͠ຖճrefreshΛݺͼग़͔ͯ͠Βऔಘɻ
ViewController ViewController͔ΒServiceΛ௨ͯ͠ RealmΛૢ࡞
ViewController @property (nonatomic, strong) EntityHoge *hoge; - (void)loadFromRealm { self.hoge
= [[HogeService shared] read:self.hogeId]; if (!self.hoge) { // no cache return; } // Show cache } - (void)loadFromAPI { NSInteger modifiedSince = (self.hoge) ? self.hoge.updatedAt : 0; [[[HogeService sharedService] fetch:self.hogeId withModifiedSince:modifiedSince] continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(BFTask *task) { // Realm͔Βऔಘͯ͠͠ViewΛߋ৽ [self loadFromRealm]; return nil; }]; } Realmʹσʔλ͕͋Δ߹ɺAPIʹมߋΛͯ͠มߋ/ࠩσʔλͷΈऔಘͯ͠ ߋ৽͕͋ͬͨσʔλͷΈViewΛߋ৽͢Δɻ BoltsඇಉظॲཧΛϝιουνΣʔϯͰهड़Ͱ͖ɺThreadࢦఆͰ͖ΔͷͰRealmΛ ѻ͍͍͢ɻNotificationͬͯͳ͍ɻ
Other Topics
RLMRealm 3FBMNͷQBUIɺॳظԽɺ3FBMNΠϯελϯεͷऔಘɺ.JHSBUJPOɺ8SJUF༻ εϨουRVFVFऔಘͳͲXSBQQFSDMBTTΛ࡞ͬͯవΊ͓ͯ͘ͱΑ͍ … + (void)prepareRealms { static dispatch_once_t once;
dispatch_once(&once, ^{ defaultDataPath = [RealmManager dataRealmPath:kRealmDataFileName]; defaultCachePath = [RealmManager cacheRealmPath:kRealmCacheFileName]; [RLMRealm setDefaultRealmPath:defaultCachePath]; [RLMRealm setDefaultRealmSchemaVersion:kCurrentSchemeVersion withMigrationBlock:^(RLMMigration *migration, uint64_t oldSchemaVersion) { }]; [RLMRealm defaultRealm]; }); } + (RLMRealm *) realm { return [RLMRealm defaultRealm]; } …
Notifications Realmͷσʔλมߋ࣌ʹॲཧ͕Ͱ͖·͕͢ Notificationsͷৄࡉใ͕ͳ͍ͷͰɺ͖Ίࡉ ͔ͳUI੍ޚ͕Ͱ͖ͳ͍ͨΊ͍ͬͯͳ͍ @property(nonatomic, strong) RLMNotificationToken *token; … self.token
= [[LVPRealms realm] addNotificationBlock:^(NSString *note, RLMRealm * realm) { // updateUI }];
Migration ςʔϒϧ࠶ߏஙॲཧ͔͔ͳ͍ͱ͍͚ͳ͍ͷͰɺ Ϟσϧ͕େ෯ʹมߋʹͳΔΑ͏ͳ߹ͭΒ ͍… ࠓͷͱ͜ΖSchemaVersion্͛Δ͚ͩͰࡁΜͰ ͍Δ
Compaction ϝϞϦܥͷCrashϩά͕૿Ճ͖ͯͨ͠ͷͰதؒ ςʔϒϧͷංେԽΛݒ೦ ̍Ҏ্ܦ͍ͬͯͨΒCompactionΛ࣮ߦ͍ͯ͠Δ
·ͱΊ ɾෳࡶͳσʔλΛେྔʹѻ͏ΞϓϦͰΩϟο ɹγϡ༻్ͱͯ͠૬ੑ͕ྑ͍ ɾRealm ͱ Bolts ҙ֎ʹ૬ੑ͕Α͍ ɾΫϥΠΞϯτʹσʔλอଘ͢Δ߹ ɹαʔόؚΊͨΞϓϦέʔγϣϯશମͷ ɹઃܭ͕େࣄ
ɾRealmνʔϜͷαϙʔτ͕ް͍
THANK YOU!