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.1k
WWDC Pre meeting
nolili
1
3.3k
FastLane with Swift
nolili
0
130
App Transport Securityとローカルネットワーキング/iOSDC Japan 2017
nolili
1
1.3k
iOS Test Night #4
nolili
0
3.7k
SwiftFriendlyObjective-C/try! Swift Tokyo 2017 RejectCon
nolili
1
810
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.8k
Other Decks in Programming
See All in Programming
Composing an API the *right* way (Droidcon New York 2024)
zsmb
2
180
『ドメイン駆動設計をはじめよう』中核の業務領域
masuda220
PRO
5
1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
0
130
Why Prism?
kddnewton
4
1.7k
上手に付き合うコンポーネントテスト
quramy
1
260
意外とフォントが大事だった話 / Font Issues on Internationalization
fumi23
0
110
LangChainの現在とv0.3にむけて
os1ma
4
940
ECMAScript、Web標準の型はどう管理されているか / How ECMAScript and Web standards types are maintained
petamoriken
3
390
全部見せます! クラシルリワードのSwiftTesting移行プロジェクト
uetyo
0
210
The Shape of a Service Object
inem
0
530
Ebitengineの1vs1ゲーム WebRTCの活用
ponyo877
0
380
XStateでReactに秩序を与えたい
gizm000
0
740
Featured
See All Featured
Statistics for Hackers
jakevdp
794
220k
Producing Creativity
orderedlist
PRO
340
39k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
5
490
Robots, Beer and Maslow
schacon
PRO
157
8.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Intergalactic Javascript Robots from Outer Space
tanoku
268
26k
How to Ace a Technical Interview
jacobian
274
23k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
663
120k
YesSQL, Process and Tooling at Scale
rocio
167
14k
Faster Mobile Websites
deanohume
304
30k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
36
2.1k
The Cost Of JavaScript in 2023
addyosmani
42
5.7k
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