Click here to Skip to main content
15,662,737 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)

            HStack {

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


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


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


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