Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
CoreDataからSwiftDataへの移行
Search
ムッチョ
November 16, 2023
220
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
CoreDataからSwiftDataへの移行
ムッチョ
November 16, 2023
Transcript
15 slides
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からの移行も簡単!
ありがとうございました!
More Decks by ムッチョ
See All by ムッチョ
AndroidアプリのUIをGeminiで生成する
musayazuju
0
140
Architecture Design for Local Database ~ Realm, CoreData, SwiftData ~
musayazuju
0
160
Generate Android App UI with Gemini
musayazuju
2
210
Databaseのことを考えずにiOSアプリを作る ローカルデータベースを使うときの アーキテクチャ設計
musayazuju
1
310
Featured
See All Featured
Believing is Seeing
oripsolob
1
280
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
350
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
660
New Earth Scene 8
popppiees
5
2.8k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k
Thoughts on Productivity
jonyablonski
76
5.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.9k
Writing Fast Ruby
sferik
630
63k
How GitHub (no longer) Works
holman
316
150k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k