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
850
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
あれやってみてー駆動から成長を加速させる / areyattemite-driven
nashiusagi
1
200
プロダクトの品質に コミットする / Commit to Product Quality
pekepek
2
770
Webエンジニア主体のモバイルチームの 生産性を高く保つためにやったこと
igreenwood
0
330
バグを見つけた?それAppleに直してもらおう!
uetyo
0
170
複雑な仕様に立ち向かうアーキテクチャ
myohei
0
170
.NET 9アプリをCGIとして レンタルサーバーで動かす
mayuki
1
770
開発者とQAの越境で自動テストが増える開発プロセスを実現する
92thunder
1
180
Discord Bot with AI -for English learners-
xin9le
1
120
fs2-io を試してたらバグを見つけて直した話
chencmd
0
220
Semantic Kernelのネイティブプラグインで知識拡張をしてみる
tomokusaba
0
180
Keeping it Ruby: Why Your Product Needs a Ruby SDK - RubyWorld 2024
envek
0
180
テストコード文化を0から作り、変化し続けた組織
kazatohiei
2
1.5k
Featured
See All Featured
Designing Experiences People Love
moore
138
23k
A better future with KSS
kneath
238
17k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
RailsConf 2023
tenderlove
29
940
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Practical Orchestrator
shlominoach
186
10k
How GitHub (no longer) Works
holman
311
140k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
2
170
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
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