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
770
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
Genieを崇めよ
kameitomohiro
0
170
フルカイテン株式会社 エンジニア向け採用資料
fullkaiten
0
12k
Argo CDとAtlantisで実現するインフラ管理のセルフサービス化──小規模SREチームで支えるプラットフォーム
cassius7
0
150
音声コミュニティを守るAI監視基盤_ 90%以上の入力削減を支えたServerless設計と運用判断
shuheioka123
0
110
GitHub Agentic Workflows を触ってみる
htkym
2
600
SREの視点で考えるSIEM活用術 〜AWS環境でのセキュリティ強化〜
cscengineer
PRO
0
360
エージェントはローカル、検証はMicroVM — Lambda MicroVMsでつくるServerless CI
fujioka6789
3
790
AIに賢く動いてもらうためのコンテキスト〜Snowflake女子会 vol.8
snowwmn0824
0
180
2026-09-08 そのJavaモダナイゼーション、AIに丸投げで大丈夫?IBM Bobで変わる品質と効率
yutanonaka
1
190
ScotSecure West 2026 - Glasgow
raybugg
0
170
アクセスキーこわい やめかたと漏らさない工夫
sassssan68
1
790
Kiro Meetup #8 Kiro アップデート (2026/3/21〜2026/9/24)
katzueno
1
230
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
510
Statistics for Hackers
jakevdp
799
230k
Agile that works and the tools we love
rasmusluckow
331
22k
GitHub's CSS Performance
jonrohan
1033
470k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Ruling the World: When Life Gets Gamed
codingconduct
0
360
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
700
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
250
Design in an AI World
tapps
1
330
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!