I have a list of remarks which I receive from an API call. I have created a loop to create TEXT from the remarks but the texts do not appear in the application. Please check the code.
I have also checked the debugger and it shows a the string present there but it doesn't create the text.
Let me know if you need any more details
I have also checked the debugger and it shows a the string present there but it doesn't create the text.
Code Block VStack{ Text("Remarks") .padding(.horizontal, 15) .font(.title2) if(currentFrResponse.remarks != nil){ List(currentFrResponse.remarks!, id:\.self){ currentRemark in VStack{ Text(currentRemark) .bold() .padding() }.padding() } } }
Let me know if you need any more details
In the end i used a ForEach loop for this. I actually wished to create a list of textfields which could be add on the basis of the remarks received from the API call. Also this list needed to be dynamic, i.e, I could add or remove the textfields dynamically by using buttons which is why I wanted to add a list...
Unfortunately I couldn't. But now I created a a for loop and then added two buttons which could add or remove the textfields and it now works perfectly.
Here is the code for this.
Unfortunately I couldn't. But now I created a a for loop and then added two buttons which could add or remove the textfields and it now works perfectly.
Here is the code for this.
Code Block ForEach(0..<remarksList.count, id: \.self) { index in TextField("Remarks", text: Binding<String>( get: {remarksList[index] }, set: {remarksList[index] = $0}) ) .padding() .background(Color("light_gray")) .foregroundColor(.black) .cornerRadius(8) .disabled(!showUpdateButton) }
Code Block if showUpdateButton { HStack{ Button(action:{ self.remarksList.append("") }) { Text("Add Remarks") } Spacer() Button(action:{ _ = self.remarksList.popLast() }) { Text("Delete Remarks") } }.padding(30) }