【发布时间】:2019-12-30 15:29:49
【问题描述】:
我有一个问题,在选择器中选择一个值后,我没有看到它被选中:
struct SampleView: View {
@FetchRequest(
entity: Category.entity(),
sortDescriptors: [
NSSortDescriptor(keyPath: \Category.title, ascending: true)
]
) var categories: FetchedResults<Category>
@State private var category = UUID()
var body: some View {
NavigationView {
VStack {
Form {
Picker(selection: $category, label: Text("Picker")) {
ForEach(categories) { cat in
Text(cat.title!)
}
}
}
}
}
}
}
我的核心数据有这两个属性:
@NSManaged public var title: String?
@NSManaged public var id: UUID?
【问题讨论】: