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
Modular Monolith Monorepo ~シンプルさを保ちながらmonorepoのメリットを最大化する~
yuisakamoto
6
570
Hotwire or React? ~アフタートーク・本編に含めなかった話~ / Hotwire or React? after talk
harunatsujita
1
120
Jakarta EE meets AI
ivargrimstad
0
750
Djangoの開発環境で工夫したこと - pre-commit / DevContainer
hiroki_yod
1
180
イマのCSSでできる インタラクション最前線 + CSS最新情報
clockmaker
4
2.3k
Click-free releases & the making of a CLI app
oheyadam
2
120
Remix on Hono on Cloudflare Workers
yusukebe
1
310
OSSで起業してもうすぐ10年 / Open Source Conference 2024 Shimane
furukawayasuto
0
110
Realtime API 入門
riofujimon
0
150
React CompilerとFine Grained Reactivityと宣言的UIのこれから / The next chapter of declarative UI
ssssota
2
120
A Journey of Contribution and Collaboration in Open Source
ivargrimstad
0
1.1k
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Featured
See All Featured
10 Git Anti Patterns You Should be Aware of
lemiorhan
655
59k
Happy Clients
brianwarren
98
6.7k
How to train your dragon (web standard)
notwaldorf
88
5.7k
The Cult of Friendly URLs
andyhume
78
6k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
1.9k
Fireside Chat
paigeccino
34
3k
Optimising Largest Contentful Paint
csswizardry
33
2.9k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
25
1.8k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Designing on Purpose - Digital PM Summit 2013
jponch
115
7k
Why Our Code Smells
bkeepers
PRO
334
57k
The Invisible Side of Design
smashingmag
298
50k
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