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
200
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CoreDataからSwiftDataへの移行
ムッチョ
November 16, 2023
More Decks by ムッチョ
See All by ムッチョ
AndroidアプリのUIをGeminiで生成する
musayazuju
0
120
Architecture Design for Local Database ~ Realm, CoreData, SwiftData ~
musayazuju
0
140
Generate Android App UI with Gemini
musayazuju
2
180
Databaseのことを考えずにiOSアプリを作る ローカルデータベースを使うときの アーキテクチャ設計
musayazuju
1
260
Featured
See All Featured
The Cult of Friendly URLs
andyhume
79
7k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
30 Presentation Tips
portentint
PRO
1
360
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
570
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
45k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.5k
Tell your own story through comics
letsgokoyo
1
1k
Raft: Consensus for Rubyists
vanstee
141
7.6k
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
460
Design in an AI World
tapps
1
280
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からの移行も簡単!
ありがとうございました!