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
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
67
Pairs iOSとトレンドの技術
muukii0803
0
1k
Thoughts about build flow
muukii0803
2
360
スマホアプリ開発で大切なこと
muukii0803
3
190
エンジニアとして働くために
muukii0803
0
210
Q. Textureは部分的に導入できますか?
muukii0803
3
2.6k
安定したチャットを実現するための アプリとAPI設計
muukii0803
17
8.5k
快適なUIを持つアプリを作るために できること
muukii0803
12
2.8k
iOS エンジニアが考える Webアプリ開発
muukii0803
3
530
Other Decks in Programming
See All in Programming
Creating Composable Callables in Contemporary C++
rollbear
0
140
Signal Forms: Details & Live Coding @enterJS 2026 in Mannheim
manfredsteyer
PRO
0
140
The NotImplementedError Problem in Ruby
koic
1
810
Contextとはなにか
chiroruxx
1
330
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.6k
Strategic Design in the Frontend: Moduliths & Micro Frontends @DDDEurope
manfredsteyer
PRO
0
100
3Dシーンの圧縮
fadis
1
770
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
180
AIで効率化できた業務・日常
ochtum
0
140
Webフレームワークの ベンチマークについて
yusukebe
0
170
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
780
Vite+ Unified Toolchain for the Web
naokihaba
0
320
Featured
See All Featured
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.8k
BBQ
matthewcrist
89
10k
Un-Boring Meetings
codingconduct
0
320
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
150
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
320
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
1
350
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
How to train your dragon (web standard)
notwaldorf
97
6.7k
Chasing Engaging Ingredients in Design
codingconduct
0
220
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
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 :)