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
CoreDataによるデータ駆動型プログラミング
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Shinji Kobayashi
March 03, 2013
Programming
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CoreDataによる データ駆動型 プログラミング
Shinji Kobayashi
March 03, 2013
More Decks by Shinji Kobayashi
See All by Shinji Kobayashi
5分でできる UITableViewのDrag & Drop
gentlesoft
0
470
自社コンテンツ配信 のためのWebView Tips
gentlesoft
2
5.6k
実践Protocol-Extension
gentlesoft
0
84
UIKitDynamicsの活用法
gentlesoft
0
610
iOS9のUIKitDynamics
gentlesoft
0
50
SwiftでUIKitDynamics
gentlesoft
0
59
Other Decks in Programming
See All in Programming
dRuby over BLE
makicamel
2
340
TypeScript+Orvalで実現する型安全かつ堅牢でスケーラブルなマルチチャネル通知基盤 / TSKaigi Night talks ~after conference~
d0riven
0
340
Dataformのリポジトリを立ち上げるときにまずやること / dataform-day0-2026
snhryt
0
160
その問い、本当に正しいですか?AI時代のエンジニアに必要な哲学と認知科学 / ai-philosophy-cognitive-science
minodriven
9
5k
OSもどきOS
arkw
0
560
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
RTSPクライアントを自作してみた話
simotin13
0
610
Creating Composable Callables in Contemporary C++
rollbear
0
130
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
2
680
Inside Stream API
skrb
1
710
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
230
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
4.6k
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
50
15k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
420
Art, The Web, and Tiny UX
lynnandtonic
304
22k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.5k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
140
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
460
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
The Curse of the Amulet
leimatthew05
1
13k
Transcript
CoreDataʹΑΔ σʔλۦಈܕ ϓϩάϥϛϯά Shinji Kobayashi GentleSoft
NameɿShinji Kobayashi Twitterɿ@gentlejkov GentleSoft Who are you? http://gentlesoft.net
Who are you? https://medpeer.jp
ΞδΣϯμ • CoreDataͬͯͳʹʁ • σʔλۦಈܕϓϩάϥϛϯάͬͯ ͳʹʁ • Ͳ͏࣮ͬͯ͢Δͷʁ
CoreDataͬͯͳʹʁ
CoreDataͱԿ͔ • Apple͕ఏڙ͢ΔσʔλӬଓԽί ϯϙʔωϯτ
CoreDataͱԿͰͳ͍͔ • not DataBase • not ORM
not DataBase ?
not ORM ?
͡Ό͋CoreDataͬͯԿͳͷ͞ • CoreDataΛཧ͢ΔΦϒδΣΫτ܈ NSManagedObjectContext σʔλͷૢ࡞Λཧ ɹNSPersistentStoreCoordinator σʔλϑΝΠϧΛཧ ɹNSManagedObjectModel σʔλͷߏΛཧ
NSManagedObjectModel ͡Ό͋CoreDataͬͯԿͳͷ͞ σʔλͷߏΛཧ
NSManagedObjectModel NSPersistentStoreCoordinator Data File ͡Ό͋CoreDataͬͯԿͳͷ͞ σʔλϑΝΠϧΛཧ
NSManagedObjectModel NSManagedObjectContext NSPersistentStoreCoordinator Data File ͡Ό͋CoreDataͬͯԿͳͷ͞ σʔλͷૢ࡞Λཧ
NSManagedObjectModel NSManagedObjectContext NSPersistentStoreCoordinator Application Program Data File ͡Ό͋CoreDataͬͯԿͳͷ͞ NSFetchRequest
NSManagedObjectModel NSManagedObjectContext NSPersistentStoreCoordinator Application Program Data File ͡Ό͋CoreDataͬͯԿͳͷ͞ NSArray
CoreDataͷ͍ํ ৽نϓϩδΣΫτͰ Master-Detail ApplicationΛબΜͰɺ Use Core DataʹνΣοΫΛ͚ͭΑ͏
CoreData͏ͱ͍͍͜ͱ͋Δͷʁ • ։ൃָ͕ɺࢼߦࡨޡ͍͢͠ •σʔλΛదʹΩϟογϡͯ͘͠ΕΔ • NSFetchedResultsController͕͑Δ
NSFetchedResultsControllerʁ • CoreDataͷσʔλͷมߋΛࢹ͠ ͯΞϓϦέʔγϣϯʹ௨ͯ͘͠Ε ΔΦϒδΣΫτ
ͭ·Γʁ • σʔλۦಈܕϓϩάϥϛϯάΛ αϙʔτ
σʔλۦಈܕ ϓϩάϥϛϯάͬͯͳʹʁ
σʔλۦಈʁ
Event User Πϕϯτۦಈʁ
Event User Display DataIO Πϕϯτۦಈʁ
Event User Data File Display DataIO Πϕϯτۦಈʁ
Event User Data File Display DataIO Πϕϯτۦಈʁ
Display Event DataIO User Data File Πϕϯτۦಈͷ໘ͳॴ Event2
Display Event DataIO User Data File DataIO Πϕϯτۦಈͷ໘ͳॴ DataIO Event2
Display Event DataIO User Data File DataIO Πϕϯτۦಈͷ໘ͳॴ DataIO Event2
Կ͔લಉ༷͡ͳ͜ͱ ॻ͍ͨͧʁ
Display Event DataIO User Data File Event2 Event3 Πϕϯτۦಈͷ໘ͳॴ
Display Event DataIO User Data File Event2 DataIO Event3 Πϕϯτۦಈͷ໘ͳॴ
DataIO
Display Event DataIO User Data File Event2 DataIO Event3 Πϕϯτۦಈͷ໘ͳॴ
DataIO Eventࣗମը໘ͱ ؔͳ͍ͧʁ
Display Event DataIO User Data File Event2 DataIO Data Manager
͖ͬ͢Γʂ ͕ͩͯʂ ͜Εɺ࣮ େม͡Όͳ͍ʁ σʔλۦಈʁ
User σʔλۦಈʁ
Event User σʔλۦಈʁ
Event DataIO User σʔλۦಈʁ
Event DataIO User Data File σʔλۦಈʁ
Event DataIO User Data File Data Manager σʔλۦಈʁ
Display Event DataIO User Data File Data Manager σʔλۦಈʁ
Display Event DataIO User Data File Event2 Data Manager σʔλۦಈʁ
Display Event DataIO User Data File Event2 DataIO Data Manager
σʔλۦಈʁ
Display Event DataIO User Data File Event2 DataIO Data Manager
͖ͬ͢Γʂ σʔλۦಈʁ
Display Event DataIO User Data File Event2 DataIO Data Manager
σʔλۦಈʁ ͕ͩͯʂ
Display Event DataIO User Data File Event2 DataIO Data Manager
σʔλۦಈʁ ͜Εɺ࣮ େม͡Όͳ͍ʁ
NSFetchedResultsController σʔλۦಈʂ Display Event DataIO User Data File Event2 DataIO
Ͳ͏࣮ͬͯ͢Δͷʁ
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller - (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath - (void)controllerDidChangeContent:(NSFetchedResultsController *)controller NSFetchedResultsController͕ ఏڙ͢Δdelegate
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller NSFetchedResultsController͕ ఏڙ͢Δdelegate σʔλͷߋ৽͕։࢝͞ΕΔࡍʹݺΕΔ
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id <NSFetchedResultsSectionInfo>)sectionInfo atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type NSFetchedResultsController͕ ఏڙ͢Δdelegate ηΫγϣϯʹߋ৽͕͋ͬͨࡍʹݺΕΔ
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath NSFetchedResultsController͕
ఏڙ͢Δdelegate σʔλʹߋ৽͕͋ͬͨࡍʹݺΕΔ
- (void)controllerDidChangeContent:(NSFetchedResultsController *)controller NSFetchedResultsController͕ ఏڙ͢Δdelegate σʔλͷߋ৽͕ྃͨ͠ࡍʹݺΕΔ
- (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type newIndexPath:(NSIndexPath *)newIndexPath ͜͜Ͱը໘ͷσʔλΛߋ৽
ߋ৽ͷ͋ͬͨΦϒδΣΫτ ߋ৽͞Εͨߦ มߋλΠϓ (C-UD+M) Ҡಈޙͷߦ
NSFetchedResultsControllerͬͯ UITableViewͷͨΊͷ͡Όʁ ͦΕ͚ͩ͡Ό͍ͬͨͳ͍
΄Μͱʹʁ https://github.com/gentlesoft/ NSFetchedResultsControllerSample
ҙʂ • ΦϒδΣΫτͷͲͷଐੑʹߋ৽͕͋ͬ ͔͔ͨΒͳ͍ • ήʔϜͳͲԠʹγϏΞͳΞϓ Ϧέʔγϣϯʹ͔ͳ͍ • didChangeObjectͷίʔϧ͕࿈ଧ͞Ε Δέʔε͕͋Δ
͝ਗ਼ௌ͋Γ͕ͱ͏ ͍͟͝·ͨ͠