Answer the question
In order to leave comments, you need to log in
How to set knowledge for Enum in structure?
I have a model
struct TimeSection: Hashable, Identifiable {
var id: Int
var type: SectionType
var timerId: Int
var fromTimestamp: Int
var toTimestamp: Int
enum SectionType: String, CaseIterable, Identifiable {
case work = "work"
case relax = "relax"
var id: String { self.rawValue }
}
struct TimeSectionDetails_Previews: PreviewProvider {
static var previews: some View {
TimeSectionDetails(timeSection: TimeSection(
id: 1,
type: TimeSection.SectionType.init(rawValue: "work"), // вот тут идет ошибка, Cannon Find S in Scope
timerId: 1,
fromTimestamp: 1627915695,
toTimestamp: 1627915900
)
)
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question