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
140
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
create_tableをしただけなのに〜囚われのuuid編〜
daisukeshinoku
0
290
DevFest - Serverless 101 with Google Cloud Functions
tunmise
0
130
なまけものオバケたち -PHP 8.4 に入った新機能の紹介-
tanakahisateru
1
130
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
570
わたしの星のままで一番星になる ~ 出産を機にSIerからEC事業会社に転職した話 ~
kimura_m_29
0
210
Kaigi on Railsに初参加したら、その日にLT登壇が決定した件について
tama50505
0
110
Fibonacci Function Gallery - Part 1
philipschwarz
PRO
0
230
ゆるやかにgolangci-lintのルールを強くする / Kyoto.go #56
utgwkk
2
460
StarlingMonkeyを触ってみた話 - 2024冬
syumai
3
280
「Chatwork」Android版アプリを 支える単体テストの現在
okuzawats
0
180
Scalaから始めるOpenFeature入門 / Scalaわいわい勉強会 #4
arthur1
1
350
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
8
1.9k
Featured
See All Featured
Building an army of robots
kneath
302
44k
Building Better People: How to give real-time feedback that sticks.
wjessup
366
19k
Bash Introduction
62gerente
609
210k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
180
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Mobile First: as difficult as doing things right
swwweet
222
9k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Designing for humans not robots
tammielis
250
25k
The Cult of Friendly URLs
andyhume
78
6.1k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Visualization
eitanlees
146
15k
How STYLIGHT went responsive
nonsquared
96
5.2k
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