Click here to Skip to main content
16,018,664 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm creating more than one textfield according to user's input. When user enters 3 then I will create 3 textfields using foreach loop but I don't know how I can handle inputs that will come from these textFields? also I want to save these inputs to my CoreData.Will I need to use a relationship?


What I have tried:

    ForEach(0..<Int(homeData.productCount)!, id: \.self){element in

    RoundedRectangle(cornerRadius: 10)
        .foregroundColor(Color(.systemGray6))
        .overlay(

            HStack {

                Image(systemName: "pencil")
                    .resizable()
                    .aspectRatio(contentMode: .fill)
                    .frame(width: 15, height: 15, alignment: .center)
                    .padding(.leading, 20)

                Spacer()

                TextField("Product \(element)", text: $myfield)

            }


        ).frame(width: UIScreen.main.bounds.width - 35, height: 50, alignment: .leading)

}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900