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
CoreDataによるデータ駆動型プログラミング
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
480
自社コンテンツ配信 のためのWebView Tips
gentlesoft
2
5.7k
実践Protocol-Extension
gentlesoft
0
86
UIKitDynamicsの活用法
gentlesoft
0
620
iOS9のUIKitDynamics
gentlesoft
0
53
SwiftでUIKitDynamics
gentlesoft
0
60
Other Decks in Programming
See All in Programming
Security issues being discussed on Web Platforms
petamoriken
0
510
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
数年滞っていたダークモード対応をおよそ2週間で完了させる
chigichan24
0
700
Intent as Code
shoppingjaws
5
710
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
200
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
130
FastAPI の並行処理モデルを完全に理解する
hoto17296
9
3.9k
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
1.7k
AIとGame Jamで、ゲームを完成させた話
takahirosaeki
0
120
Family mrubyの進捗
kishima
1
110
AWS Step Functions 大規模並列の壁を越える / jaws-sonic-2026-niigata-step-functions
kasacchiful
PRO
1
430
GKE アップグレード前に知っておきたい Blue/Green と PDB の関係
stkk
0
160
Featured
See All Featured
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Making the Leap to Tech Lead
cromwellryan
135
10k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.9k
The Curious Case for Waylosing
cassininazir
1
500
Darren the Foodie - Storyboard
khoart
PRO
3
3.9k
[SF Ruby Conf 2025] Rails X
palkan
2
1.4k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
So, you think you're a good person
axbom
PRO
2
2.1k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
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ͷίʔϧ͕࿈ଧ͞Ε Δέʔε͕͋Δ
͝ਗ਼ௌ͋Γ͕ͱ͏ ͍͟͝·ͨ͠