Swift UI

Extra arguments at positions #11, #12, #13, #14, #15 in call

HOW CAN I FIX THIS PROPLEM !!

Answered by AndyJJ in 750904022

Well if you try to imagine us imagining what your code looks like, you would see some confused faces.

We have no idea without seeing your code. It could be anything.

Accepted Answer

Well if you try to imagine us imagining what your code looks like, you would see some confused faces.

We have no idea without seeing your code. It could be anything.

Accepted Answer

What @AndyJJ said, plus that means you are calling a function with 15 arguments where the function was declared only with 10.

In SwiftUI, that could be due to creating a view with more that 10 subviews. You should Group { } to group subviews by groups of 10 max.

Example here on using Group: https://www.hackingwithswift.com/quick-start/swiftui/how-to-group-views-together

So, show code.

//
//  ContentView.swift
//  LandDataScreen
//
//  Created by Noura on 10 / 04/ 2023.
//

 import SwiftUI

 struct ContentView: View {
    @State private var LandName = ""
     @State private var LandID = ""
     @State private var price = ""
     @State private var LandConTerm = ""
     @State private var LandArea = ""
     

     @State private var LandCountry = ""
     @State private var LandCity = ""
     @State private var LandZipCode = ""
     @State private var LandAdress = ""
     
     @State private var LandStatus = ""
     @State private var SoilType = ""
     @State private var LandImage = ""
     @State private var LandDescription = ""
     
     
     var body: some View {
         NavigationView {
             
             VStack {
               
            Text ("بيانات الأرض * ")
                     .foregroundColor(Color("text"))
                     .offset(x:100,y:-220)
                     .font(.title)
                   
                Text("البيانات الأساسية* ")
                     .foregroundColor(Color("Text 1"))
                     .offset(x:110,y:-210)
                     .font(.subheadline)
                 
                TextField("أدخل أسم الأرض", text: $LandName)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
               TextField("أدخل رقم الأرض", text: $LandID)
                     .padding(60)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
                 TextField("أدخل السعر(ريال سعودي)", text: $price)
                     .padding(30)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
                 
                 TextField("أدخل المدة(شهريا)", text: $LandConTerm)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
                 TextField("أدخل (متر مربع)", text: $LandArea)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
               Text("بيانات الموقع  ")
                     .foregroundColor(Color("Text 1"))
                     .offset(x:110,y:-200)
                     .font(.subheadline)
                 
                TextField("أدخل اسم منطقتك", text: $LandCountry)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
                TextField(" أدخل  اسم مدينتك", text: $LandCity)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
              TextField("أدخل الرمز البريدي", text: $LandZipCode)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
              TextField("أدخل عنوانك", text: $LandAdress)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
                 Text(" وصف الأرض")
                     .foregroundColor(Color("Text 1"))
                     .offset(x:110,y:-200)
                     .font(.subheadline)
                 
                 
                 
                 
                 
                 TextField("أدخل نوع التربة", text: $SoilType)
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
                 
                 
                 
                 
                 //مكان اختيار الصورة
                 
                 
                 
                 
                 TextField("أدخل الوصف  ", text: $LandDescription )
                     .padding(55)
                     .frame(width: 250, height: 30)
                     .background(Color.black.opacity(0.05))
                     .cornerRadius(10)
                     .offset(x:-50,y:-210)
                 
                 Button {
                     
                 } label: {
                     Text("حفظ")
                         .font(.title2.width(.standard))
                         .foregroundColor(.white)
                         .frame(width:250,height: 50)
                         .background(Color("Text 2"))
                         .mask(RoundedRectangle(cornerRadius: 20 , style:.continuous))
                 }
                
                 
               
                 
             }
             .padding()
         }
     }
     
     struct ContentView_Previews: PreviewProvider {
         static var previews: some View {
             ContentView()
         }
     }
 }
Accepted Answer

You have 16 elements in the VStack so @Claude31 is apparently right.

Also you use hard coded offsets a lot. Maybe just let SwiftUI do the layout and control it using spacing, padding and Spacers.

How I create textfield to select photo in swift? How I create checkbox in swift ?

Swift UI
 
 
Q