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
Modern Core Data(iOS 10)
Search
Noritaka Kamiya
September 28, 2016
Programming
0
1.3k
Modern Core Data(iOS 10)
potatotips #33
http://potatotips.connpass.com/event/38557/
Noritaka Kamiya
September 28, 2016
Tweet
Share
More Decks by Noritaka Kamiya
See All by Noritaka Kamiya
キラリと光るテクニック、アプリをデモするときの心構え/iOSDC Japan 2018
nolili
4
3.2k
WWDC Pre meeting
nolili
1
3.3k
FastLane with Swift
nolili
0
130
App Transport Securityとローカルネットワーキング/iOSDC Japan 2017
nolili
1
1.4k
iOS Test Night #4
nolili
0
3.8k
SwiftFriendlyObjective-C/try! Swift Tokyo 2017 RejectCon
nolili
1
840
iOSアプリ開発のCI/CD環境とユビレジでのtry / CI CDNight
nolili
1
1.7k
ユビレジiOSアプリ開発のCI/CD環境 / iOS Test Night #1
nolili
5
2.3k
iOS I/O 2016 アクセサリといっしょ
nolili
1
1.9k
Other Decks in Programming
See All in Programming
RubyLSPのマルチバイト文字対応
notfounds
0
120
Amazon Bedrock Agentsを用いてアプリ開発してみた!
har1101
0
330
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
6
1.1k
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
1
110
聞き手から登壇者へ: RubyKaigi2024 LTでの初挑戦が 教えてくれた、可能性の星
mikik0
1
130
イベント駆動で成長して委員会
happymana
1
320
現場で役立つモデリング 超入門
masuda220
PRO
15
3.2k
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
120
EventSourcingの理想と現実
wenas
6
2.3k
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
220
Flutterを言い訳にしない!アプリの使い心地改善テクニック5選🔥
kno3a87
1
150
Click-free releases & the making of a CLI app
oheyadam
2
110
Featured
See All Featured
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
How to Ace a Technical Interview
jacobian
276
23k
The Pragmatic Product Professional
lauravandoore
31
6.3k
GraphQLとの向き合い方2022年版
quramy
43
13k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
It's Worth the Effort
3n
183
27k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
506
140k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Building Your Own Lightsaber
phodgson
103
6.1k
For a Future-Friendly Web
brad_frost
175
9.4k
Why Our Code Smells
bkeepers
PRO
334
57k
Transcript
import CoreData ࠷ۙɺCore DataͲ͏Ͱ͔͢? @nolili Noritaka Kamiya
None
None
None
None
CoreData
CoreData
NSAsynchronousFetchRequest NSFetchRequest<ResultType> NSPersistentContainer
NSFetchRequest<ResultType>
let request = NSFetchRequest(entityName: "Message") context.fetch(request) as! [Message] Force Casting!
Before
let request: NSFetchRequest<Message> = Message.fetchRequest() // fetchRequest() -> NSFetchRequest<T> ࣗಈੜ͞ΕΔ
let messages = context.fetch(request) // [Message] After
NSFetchRequest<ResultType> NSManagedObjectͷαϒΫϥεΛfetch͢Δ߹ʹศར SwiftϑϨϯυϦʔʹ Swift/Objective-C
NSAsynchronousFetchRequest
let request: NSFetchRequest<Message> = Message.fetchRequest() let asyncRequest = NSAsynchronousFetchRequest<Message>(fetchRequest: request)
{ result in let messages = messages = result.finalResult ?? [] } try! managedObjectContext.execute(asyncRequest)
let result: NSAsynchronousFetchResult = try! managedObjectContext.execute(asyncRequest) result.cancel()
NSAsynchronousFetchRequest closureΛͬͨඇಉظϑΣονָ͕ʹॻ͚Δ Ωϟϯηϧ͕Ͱ͖Δ ϑΣονͷProgressऔಘͰ͖Δ iOS 8~
NSPersistentContainer
Α͋͘ΔCore DataͷηοτΞοϓ
/41FSTJTUFOU4UPSF
/4.BOBHFE0CKFDU.PEFM /41FSTJTUFOU4UPSF
/41FSTJTUFOU4UPSF$PPSEJOBUPS /4.BOBHFE0CKFDU.PEFM /41FSTJTUFOU4UPSF
/41FSTJTUFOU4UPSF$PPSEJOBUPS /4.BOBHFE0CKFDU.PEFM /4.BOBHFE0CKFDU$POUFYU /41FSTJTUFOU4UPSF
/41FSTJTUFOU4UPSF$PPSEJOBUPS /4.BOBHFE0CKFDU.PEFM /4.BOBHFE0CKFDU$POUFYU /4.BOBHFE0CKFDU$POUFYU 1SJWBUF2VFVF /41FSTJTUFOU4UPSF
ͭΒ͍
ॳݟࡴ͠
NSPersistentContainer
/41FSTJTUFOU$POUBJOFS NSPersistentContainer(name: "iOS10Sampler")
/41FSTJTUFOU4UPSF$PPSEJOBUPS /4.BOBHFE0CKFDU.PEFM /4.BOBHFE0CKFDU$POUFYU /4.BOBHFE0CKFDU$POUFYU 1SJWBUF2VFVF /41FSTJTUFOU4UPSF NSPersistentContainer(name: "iOS10Sampler") /41FSTJTUFOU$POUBJOFS
It just works
NSPersistentContainer (iOS 10~) Α͋͘ΔCoreDataͷηοτΞοϓΛ؆ུԽ طʹ͍ͬͯΔਓʹͨΓલ͔͠Εͳ͍͚Ͳͱ͖ͬͭʹ͘͞؇͞Ε͍ͯΔ ۜͷؙͰͳ͍ɻCoreDataΛ͍͜ͳͨ͢Ίʹ֮͑ͳ͚Ε͍͚ͳ͍͜ͱଟ͍ɻ NSPersistentStoreDescription Λ͑ࡉ͔ͳઃఆมߋՄ
None
None
References iOS 10 Sampler https://github.com/shu223/iOS-10-Sampler What’s new in Core Data
https://developer.apple.com/videos/play/wwdc2016/242/ SwiftʴCore DataʹΑΔiOSΞϓϦϓϩάϥϛϯά (ํՆࢠɺ ؙࢁ߂ࢻ) https://book.mynavi.jp/ec/products/detail/id=50729
https://www.wantedly.com/projects/61105
import CoreData ࠷ۙɺCore DataͲ͏Ͱ͔͢? @nolili Noritaka Kamiya