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
230
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.8k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
280
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.3k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.8k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
240
The Curse of the Amulet
leimatthew05
1
9.9k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
100
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
0
220
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
Mobile First: as difficult as doing things right
swwweet
225
10k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
5.4k
Testing 201, or: Great Expectations
jmmastey
46
8.1k
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からの移行も簡単!
ありがとうございました!