Post

Replies

Boosts

Views

Activity

Reply to Variable for DestinationView
struct ZodiacSign: Identifiable { let id = UUID() var name: String var Symbol: String var DestinationView: View } var starSigns = [ ZodiacSign(name: "Aries", Symbol: "♈︎", DestinationView: AriesView()), ZodiacSign(name: "Taurus", Symbol: "♉︎", DestinationView: TaurusView()), ZodiacSign(name: "Gemini", Symbol: "♊︎", DestinationView: GeminiView()), ZodiacSign(name: "Cancer", Symbol: "♋︎", DestinationView: CancerView()), ZodiacSign(name: "Leo", Symbol: "♌︎", DestinationView: LeoView()), ZodiacSign(name: "Virgo", Symbol: "♍︎", DestinationView: VirgoView()), ZodiacSign(name: "Libra", Symbol: "♎︎", DestinationView: LibraView()), ZodiacSign(name: "Scorpio", Symbol: "♏︎", DestinationView: ScorpioView()), ZodiacSign(name: "Sagittarius", Symbol: "♐︎", DestinationView: SagittariusView()), ZodiacSign(name: "Capricorn", Symbol: "♑︎", DestinationView: CapricornView()), ZodiacSign(name: "Aquarius", Symbol: "♒︎", DestinationView: AquariusView()), ZodiacSign(name: "Pisces", Symbol: "♓︎", DestinationView: PiscesView()) ] struct ContentView: View { var body: some View { VStack { List { ForEach(starSigns) {ZodiacSign in NavigationLink(destination: ZodiacSign.DestinationView) { Text(ZodiacSign.Symbol) Text(ZodiacSign.name) } } } } } } struct AriesView: View { var body: some View { VStack { } } } struct TaurusView: View { var body: some View { VStack { } } } struct GeminiView: View { var body: some View { VStack { } } } struct CancerView: View { var body: some View { VStack { } } } struct LeoView: View { var body: some View { VStack { } } } struct VirgoView: View { var body: some View { VStack { } } } struct LibraView: View { var body: some View { VStack { } } } struct ScorpioView: View { var body: some View { VStack { } } } struct SagittariusView: View { var body: some View { VStack { } } } struct CapricornView: View { var body: some View { VStack { } } } struct AquariusView: View { var body: some View { VStack { } } } struct PiscesView: View { var body: some View { VStack { } } } This is the full code, line 5 is where I was referring to earlier, I would like to add the destination in each one, please could you explain how I would do this.
Sep ’24