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
CoreDataからSwiftDataへの移行
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ムッチョ
November 16, 2023
1
170
CoreDataからSwiftDataへの移行
ムッチョ
November 16, 2023
Tweet
Share
More Decks by ムッチョ
See All by ムッチョ
AndroidアプリのUIをGeminiで生成する
musayazuju
0
95
Architecture Design for Local Database ~ Realm, CoreData, SwiftData ~
musayazuju
0
120
Generate Android App UI with Gemini
musayazuju
2
150
Databaseのことを考えずにiOSアプリを作る ローカルデータベースを使うときの アーキテクチャ設計
musayazuju
1
210
Featured
See All Featured
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
320
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
920
We Are The Robots
honzajavorek
0
170
jQuery: Nuts, Bolts and Bling
dougneiner
65
8.4k
4 Signs Your Business is Dying
shpigford
187
22k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.1k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.6k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
260
Designing Experiences People Love
moore
144
24k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Transcript
CoreDataから SwiftDataへの移行
自己紹介 • ヤズジュ夢佐(ムッチョ) • iOSエンジニア • 11月1日にVoicy入社(2週間) • マッチングアプリ->オンライン英会話アプ リ->Voicy
Mucchoo Mucchooooo
個人開発もやってます! 英単語学習アプリ
SwiftDataとは • iOS17で登場 • CoreDataを使いやすくしたもの • SwiftUIと相性がいい CoreDataとは • 端末内にデータを保存できる
• CloudKitを使って複数の端末でデータを共有す ることも可能
移行の3Step 1.Schema (構造) 3.Model Context (CRUD処理) 2.Model Container (Persistence)
Schema 1. .xcdatamodeld fileを選択 2. Editor -> Create SwiftData Code
→
None
↑
Persistence
Model Container • アプリで使いたいModel Typeを全て指定 • WindowGroupにセットす るだけで、 @Environmentから model
contextにアクセス できる
NSManagedObjectContext - CRUD処理
Model Context • CRUD処理全般 • Save Call不要 ->自動保存されます
@Query • データ自動更新 • SwiftUI画面自動更新 • 配列のFilter, Sort操作が簡単 for SwiftUI
まとめ • SwiftDataをSwiftUIと合わせて使うことで データの扱いが楽になる • CoreDataからの移行も簡単!
ありがとうございました!