Complete the code to import the framework needed for SwiftData.
import [1]
You need to import SwiftData to use the modern persistence features.
Complete the code to declare a SwiftData model class named 'Note'.
@Model class [1] { var text: String init(text: String) { self.text = text } }
The model class should be named Note with a capital N to follow Swift naming conventions.
Fix the error in the code to create a SwiftData container in the app struct.
var body: some Scene {
WindowGroup {
ContentView()
.modelContainer(for: [1].self)
}
}The model container needs the model type Note.self with the exact class name.
Fill both blanks to declare a SwiftData model with an integer id and a string title.
@Model class Task { var id: [1] var title: [2] init(id: Int, title: String) { self.id = id self.title = title } }
The id should be an Int and the title a String.
Fill all three blanks to create a SwiftData model with a UUID id, a string name, and a boolean done flag.
@Model class Item { var id: [1] = [2]() var name: [3] var done: Bool = false init(name: String) { self.name = name } }
The id is a UUID initialized with UUID(), and name is a String.
