Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CoreDataからSwiftDataへの移行
Search
ムッチョ
November 16, 2023
1
160
CoreDataからSwiftDataへの移行
ムッチョ
November 16, 2023
Tweet
Share
More Decks by ムッチョ
See All by ムッチョ
AndroidアプリのUIをGeminiで生成する
musayazuju
0
93
Architecture Design for Local Database ~ Realm, CoreData, SwiftData ~
musayazuju
0
120
Generate Android App UI with Gemini
musayazuju
2
140
Databaseのことを考えずにiOSアプリを作る ローカルデータベースを使うときの アーキテクチャ設計
musayazuju
1
200
Featured
See All Featured
Making Projects Easy
brettharned
120
6.5k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
180
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Groundhog Day: Seeking Process in Gaming for Health
codingconduct
0
62
GraphQLの誤解/rethinking-graphql
sonatard
73
11k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.2k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
0
98
GitHub's CSS Performance
jonrohan
1032
470k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.7k
Building the Perfect Custom Keyboard
takai
1
660
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
100
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からの移行も簡単!
ありがとうございました!