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
New Library for CoreData
Search
Muukii
July 13, 2015
Programming
2.9k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
New Library for CoreData
Muukii
July 13, 2015
More Decks by Muukii
See All by Muukii
Problem Solving from the Abstraction Layer
muukii0803
1
76
Pairs iOSとトレンドの技術
muukii0803
0
1k
Thoughts about build flow
muukii0803
2
360
スマホアプリ開発で大切なこと
muukii0803
3
200
エンジニアとして働くために
muukii0803
0
220
Q. Textureは部分的に導入できますか?
muukii0803
3
2.6k
安定したチャットを実現するための アプリとAPI設計
muukii0803
17
8.6k
快適なUIを持つアプリを作るために できること
muukii0803
12
2.8k
iOS エンジニアが考える Webアプリ開発
muukii0803
3
540
Other Decks in Programming
See All in Programming
アクセシビリティから考える情報設計
high_g_engineer
0
380
新卒PdEのリアル
ryu1013
1
500
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
170
世界の中心で、AI(App Intents)をさけぶ ー App Intents中心設計の実践ガイド
touyou
0
610
フロントエンドUIフレームワークのこれまでとこれから
ssssota
5
2.8k
TiDB Cloudのカスタムコントローラーによるオートスケール対応
takaidohigasi
0
130
GraphRAGのKnowledge Graphを 直接!見る/View-GraphRAG's-KnowledgeGraph-directly!
tyumugi1113
1
340
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
210
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
3.4k
cdk deploy JawsSonic #MARATHONしながらAWSリソースをデプロイしてみよう
akihisaikeda
2
140
Jetpack Compose メカニズム
skydoves
0
440
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
370
Featured
See All Featured
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Designing for humans not robots
tammielis
254
26k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.9k
A Soul's Torment
seathinner
8
3.6k
The Limits of Empathy - UXLibs8
cassininazir
1
680
Marketing to machines
jonoalderson
1
5.8k
Fireside Chat
paigeccino
43
4k
A Tale of Four Properties
chriscoyier
163
24k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
890
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
590
Odyssey Design
rkendrick25
PRO
2
810
Designing for Timeless Needs
cassininazir
1
480
Transcript
New Library for CoreData Hiroshi Kimura potatotips #19
ଜ Hiroshi Kimura iOS Developer eureka, Inc. @muukii0803
None
None
None
CoreStore https://github.com/JohnEstropia/CoreStore
Developer Hiroshi Kimura eureka, Inc. @muukii0803 John Estropia eureka, Inc.
@JohnEstropia
Good things :)
Good things :) • SwiftͰॻ͔Ε͍ͯΔ
Good things :) • SwiftͰॻ͔Ε͍ͯΔ • ϝΠϯεϨουͷContextRead-Only ॻ͖ࠐΈͯ͢SerialʹBackgroundContextͰߦΘΕΔͨΊɺ ҆શʹಈ࡞͢Δઃܭ
Good things :) • SwiftͰॻ͔Ε͍ͯΔ • ϝΠϯεϨουͷContextRead-Only ॻ͖ࠐΈͯ͢SerialʹBackgroundContextͰߦΘΕΔͨΊɺ ҆શʹಈ࡞͢Δઃܭ •
ෳͷSQLiteϑΝΠϧ͕༻Մೳ (ConfigurationͰ͚Δ)
Good things :) • SwiftͰॻ͔Ε͍ͯΔ • ϝΠϯεϨουͷContextRead-Only ॻ͖ࠐΈͯ͢SerialʹBackgroundContextͰߦΘΕΔͨΊɺ ҆શʹಈ࡞͢Δઃܭ •
ෳͷSQLiteϑΝΠϧ͕༻Մೳ (ConfigurationͰ͚Δ) • Observer͕༻ҙ͞Ε͍ͯΔ (FRCΛॻ͔ͳͯ͘ྑ͘ͳΔ)
Good things :) • SwiftͰॻ͔Ε͍ͯΔ • ϝΠϯεϨουͷContextRead-Only ॻ͖ࠐΈͯ͢SerialʹBackgroundContextͰߦΘΕΔͨΊɺ ҆શʹಈ࡞͢Δઃܭ •
ෳͷSQLiteϑΝΠϧ͕༻Մೳ (ConfigurationͰ͚Δ) • Observer͕༻ҙ͞Ε͍ͯΔ (FRCΛॻ͔ͳͯ͘ྑ͘ͳΔ) • ϚΠάϨʔγϣϯΛαϙʔτ
Usage
DataStack struct Stack { static let data: DataStack = {
let dataStack = DataStack(modelName: "CoreData") dataStack.addSQLiteStoreAndWait( "CoreData.sqlite", configuration: nil, resetStoreOnMigrationFailure: true ) return dataStack }() } SQLiteʹඥͮ͘DataStackΛੜ͠·͢
struct Stack { static let dataA: DataStack = { let
dataStack = DataStack(modelName: "StackSetupDemo") dataStack.addSQLiteStoreAndWait( "CoreData.sqlite", configuration: "Configuration_A", resetStoreOnMigrationFailure: true ) return dataStack }() static let dataB: DataStack = {...} static let dataC: DataStack = {...} } Configuration͝ͱʹDataStackͷੜ͕Մೳ ࠓճConfigurationΛΘͳ͍ํ๏ͰਐΊ͍͖ͯ·͢ɻ
let people = Stack.data.fetchAll( From(MyPersonEntity), Where("age > 30"), OrderBy(.Ascending("name"), .Descending("age")),
Tweak { (fetchRequest) -> Void in fetchRequest.includesPendingChanges = false } ) Fetch NSSortDescriptor, NSPredicateΘͣʹࢦఆ ࡉ͔͍ઃఆTweakͰࢦఆՄೳ
Stack.data.beginAsynchronous { (transaction) -> Void in let qrcode = transaction.create(Into(QRCode))
let codes = transaction.fetch( . . . ) transaction.commit() { result in switch result { case .Success(let hasChanges): success?() case .Failure(let error): failure?(error: error) } } } Create - Update
ViewController Fetch - Observe
Fetch
Controller͔ΒCoreDataΛ͏࣌ͬͯ
Controller͔ΒCoreDataΛ͏࣌ͬͯ NSFetchedResultsController ?
Controller͔ΒCoreDataΛ͏࣌ͬͯ
Controller͔ΒCoreDataΛ͏࣌ͬͯ ManagedObjectListController
var codes: ManagedObjectListController<QRCode> = { return Stack.data.observeObjectList( From(QRCode), Where("removed ==
false”), OrderBy(.Descending("readAt")) ) }() Controllerʹදࣔ͢ΔΦϒδΣΫτͷ݅Λࢦఆ
codes.numberOfSections() SectionͷΛऔಘ
codes.numberOfObjectsInSection(section) Section͔ΒObjectͷΛऔಘ
let code = codes[indexPath] NSIndexPath͔ΒObjectΛऔಘ
Observe
codes.removeObserver(self) codes.addObserver(self) Observe Observeͷ։࢝ Observeͷऴྃ
protocol ManagedObjectListChangeObserver • WillChange • Insert • Delete • Update
• Move • InsertSection • deleteSection • DidChange GenericsͰ࣮͞Ε͍ͯΔͨΊɺas ͕ෆཁ
Conclusion • DataStackΛϕʔεʹಈ࡞͢Δ • Fetchͷهड़͕γϯϓϧ • DataStack͝ͱʹγϦΞϧΩϡʔͰಈ࡞͢ΔͨΊ҆શ • ViewControllerͱͷ࿈ܞ͕؆୯ •
ϚΠάϨʔγϣϯ͕ॆ࣮ ΠϯΫϦϝϯλϧʹϚΠάϨʔγϣϯ͢Δ͜ͱՄೳ • GenericsͰ࣮͞Ε͍ͯΔͨΊμΠφϛοΫΩϟετ͕ݮΒͤΔ
Swift2.0
Thank you :)
Thank you :)