I'm new to swift and kind of struggling to piece swift to swiftui. Lot of my struggles come from not being find documentation for swiftui. I'm trying to pass data received from closure to ForEach loop inside modifier and its throwing error. I know its not the correct way to do it but I don't know why. I don't know why I can't pass closure call(takeReqeust) outside on .onAppear or right inside of NavigationView braces. Please advice what should I do. And send me to the right direction to look for future reference.
Thanks!!
var body: some View {
NavigationView{
List{
Text(data)
.onAppear {
takeReqeust { (data, error) in
let first = data.description
self.data = first
/* ForEach(self.data, id: \.self){
d in
Text(d.description.capitalized)
}*/
}
}
}.navigationBarTitle("Details")
}