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
Yuji Hato
June 25, 2015
Technology
100
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
780
Multiplatform Engineering Roadmap for the Future
dekatotoro
1
180
Introduction to RIBs
dekatotoro
5
1.5k
継続的な開発スタイル 「AbemaTV iOSアプリを週一で リリースしている話」
dekatotoro
6
4.3k
iOS Adaptive UI - 解像度の異なるデバイスや画面の向きに対応する 最適なレイアウトへ -
dekatotoro
0
560
動画アプリをなめらかに動かす技術 - iOS -
dekatotoro
0
510
5分で学ぶ差分更新とRxDataSources
dekatotoro
0
380
AbemaTV モバイルアプリの開発体制と 開発プロセスの話
dekatotoro
0
290
Other Decks in Technology
See All in Technology
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
0
230
ブラウザとサーバーから考えるAI時代のフロントエンド監視
shogo4131
3
670
AI駆動開発の時代になったのでトヨタ生産方式から見直す
terurou
6
5.5k
Codex概要
ymiya55
0
490
自作バイナリを動かす「入口」8選
puhitaku
1
1.2k
「事実」を「計測」して、「解釈」する 〜AWS Lambdaのメモリ最適解の見つけ方〜
maimyyym
0
120
Kiro Crewをはじめよう
kizawa2020
1
120
使いこなすために知っておきたい Azure SRE Agent アンチパターン
torumakabe
2
430
The seven pitfalls of AI (revised version)
ufried
0
310
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
550
DevelopersIO 2026 知識の地図を描く ─ オントロジーとは何か?
ishikawa_satoru
1
1.2k
オンラインゲームのシステム全体像 - コロプラ 2026年度 新卒研修
colopl
0
1k
Featured
See All Featured
Believing is Seeing
oripsolob
1
240
Code Reviewing Like a Champion
maltzj
529
40k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
510
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
Information Architects: The Missing Link in Design Systems
soysaucechin
1
1.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
A Modern Web Designer's Workflow
chriscoyier
699
190k
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Designing Powerful Visuals for Engaging Learning
tmiket
1
600
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
450
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
860
Bash Introduction
62gerente
615
220k
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!