Apple just unveiled SwiftData, the all new framework for Apple Platforms, at WWDC 2023!
Here's an iOS note taking application built to demonstrate various operations and persistance of data in SwiftData and SwiftUI!
I've tried to demonstrate CRUD operations using this app:
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-06.at.21.12.32.mp4
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-06.at.21.15.33.mp4
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-06.at.21.15.51.mp4
@Model
class Note {
var title: String
var content: String
init(title: String, content: String) {
self.title = title
self.content = content
}
}
Setting up this model as a model container in the SDNotesApp.swift
file so as to extract context out of it in our views and controllers:
import SwiftUI
@main
struct SDNotesApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.modelContainer(for: [Note.self])
}
}
}
developer.apple.com/documentation/SwiftData
I generated this super cool icon for this app in less than 10 seconds, oh boy, DALL-E is so good!