Conversation

Fahim Farook

I was curious as to what the underlying data format for SwiftData was …

Apparently, I missed this during the keynote (or I did hear it but didn’t pay enough attention) but it appears that SwiftData uses Core Data (or something pretty similar to Core Data) under the hood.

The screenshot shows the DB used by a sample SwiftData app and the file is simply an SQLite DB. And on a cursory inspection, the data structures look pretty similar to how Core Data stores data 🙂

Of course, I don’t use Core Data much, so I can’t be absolutely sure, but I do have to wonder how it would work if you had a Core Data-based app and simply wanted to switch over to SwiftData? Is there a way to use the existing data without any migration at all?

Interesting to consider …

At least one thing I know of for sure is that there’s an easy way to view/modify SwiftData persisted data since the underlying database is SQLite 🙂

#Apple #WWDC2023 #SwiftData #DataPersistence
Screenshot of an SQLite databas…
1
1
1

@f It uses the same persistent store as Core Data. The sample code shows an example of a Core Data main app and Swift Data widget both writing to the same persistent store.

1
0
1
@kharrison I think I missed that … which video was that? Or is this one of the sample apps provided for WWDC? I hadn’t looked at those …
1
0
0

@f There’s a sample WWDC app but I’m guessing it is covered in the sessions as well

1
0
0
@kharrison Found the sample code you were talking about — Sorry, should have looked before asking 🙂 I’m sure it’ll be covered in the sessions too but was just wondering how I’d missed it since I thought I watched all the videos that have been released so far …
0
0
0