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
ムッチョ
November 16, 2023
1
180
CoreDataからSwiftDataへの移行
ムッチョ
November 16, 2023
Tweet
Share
More Decks by ムッチョ
See All by ムッチョ
AndroidアプリのUIをGeminiで生成する
musayazuju
0
99
Architecture Design for Local Database ~ Realm, CoreData, SwiftData ~
musayazuju
0
120
Generate Android App UI with Gemini
musayazuju
2
150
Databaseのことを考えずにiOSアプリを作る ローカルデータベースを使うときの アーキテクチャ設計
musayazuju
1
220
Featured
See All Featured
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
0
230
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
130
[SF Ruby Conf 2025] Rails X
palkan
2
820
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
760
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
How to Think Like a Performance Engineer
csswizardry
28
2.5k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
140
Faster Mobile Websites
deanohume
310
31k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
AI: The stuff that nobody shows you
jnunemaker
PRO
3
360
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
97
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からの移行も簡単!
ありがとうございました!