import SwiftUI
import CoreData
struct AddTaskView: View {
@Environment(\.managedObjectContext) private var viewContext
@Environment(\.presentationMode) var presentationMode
@FetchRequest(entity: Task.entity(), sortDescriptors: [])
var tasks: FetchedResults<Task>
@FetchRequest(entity: DailyScore.entity(), sortDescriptors: [NSSortDescriptor(key: "date", ascending: false)])
var scores: FetchedResults<DailyScore>
let types = ["Exercise", "German", "Cold Shower", "Fast Food"]
@State var selectedTaskIndex = 0
@State var newType = ""
var body: some View {
I can't figure out why @State var newType = ""
causes the program to crash. (and it is independent of usage, so that is irrelevant as far as I'm aware)
更新:这似乎只是一个 Xcode 错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.