使用CoreData我不知道如何解决该问题:
错误: Cannot convert value of type 'NSSet?' to expected argument type 'Range<Int>'
private func displayTopics(subject: Subject) -> some View {
NavigationView {
Form {
List {
ForEach(subject.topics) { topic in
NavigationLink(
destination: Text("Destination"),
label: {
Text("Navigate")
})
}
}
}
}
我该怎么办?
ForEach不了解NSSet
,您必须将其转换为数组:
if subject.topics != nil {
ForEach(Array(subject.topics! as Set), id: \.self) { topic in
NavigationLink(
destination: Text("Destination"),
label: {
Text("Navigate")
})
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句