Currently I'm learning SwiftUI and there's a problem which I am facing. Compiler is unable to type check the expression.
It all started when I added Text(update.date). Also, Update is the structure which I have created where one of the data members is date of type String.
Is it related to the length of the code??
I have added the code and snapshot of the error.
import SwiftUI
struct UpdateList: View {
var body: some View {
NavigationView {
List(updateData) { update in
NavigationLink(destination: Text(update.text)) {
VStack(alignment: .leading) {
Text(update.title)
.font(.system(size: 20, weight: .bold))
Text(update.text)
.font(.subheadline)
.lineLimit(2)
.foregroundColor(Color(#colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1)))
Text(update.date) //all the errors occurred when typed this
.forgroundColor(.secondary)
}
}
}
.navigationBarTitle(Text("Updates"))
}
}
}
struct UpdateList_Previews: PreviewProvider {
static var previews: some View {
UpdateList()
}
}
struct Update: Identifiable{
var id = UUID()
var image: String
var title: String
var text: String
var date: String
}
let updateData: [Update] = [
Update(image: "Card1", title: "SwiftUI Advanced", text: "Take your app to App Store with advanced techniques like API data, packages and CMS", date: "JAN 1"),
Update(image: "Card2", title: "WebFlow", text: "Design and animate a high converting landing page with advanced interations, payments and CMS", date: "OCT 17"),
Update(image: "Card3", title: "ProtoPie", text: "Quickly Prototype advanced animations nd interactions for mobile and Web", date: "AUG 27"),
Update(image: "Card4", title: "SwiftUI", text: "Learn how to code custom UI, animations and gestures and components in Xcode 11", date: "JUNE 26"),
Update(image: "Card5", title: "Framer Playground", text: "Create powerful animations and interactions with Framer X code editor", date: "JUNE 11")
]
Any suggestions??
Here's the snapshot: https://i.stack.imgur.com/LXOrH.png
Thanks in advance