Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extra arguments at positions #11, #12 in call SwiftUI [duplicate]

Tags:

swift

swiftui

I keep on getting an "Extra arguments at positions #11, #12 in call" error on my toggle switch in SwiftUI. I've seen other people have the "Extra Arguments in call" error, but the answers didn't seem to help; plus, my error says "positions #11, 12", which I haven't seen happen for others. I am using the Xcode 12 beta if that makes a difference.

import SwiftUI

let defaults = UserDefaults.standard

let notifsEnabled = defaults.bool(forKey: "NotifsEnabled")




struct Settings: View {
    @State var class11: String = defaults.string(forKey: "class11") ?? ""
    @State var class12: String = defaults.string(forKey: "class12") ?? ""
    @State var class13: String = defaults.string(forKey: "class13") ?? ""
    @State var class14: String = defaults.string(forKey: "class14") ?? ""
    
    @State var class21: String = defaults.string(forKey: "class21") ?? ""
    @State var class22: String = defaults.string(forKey: "class22") ?? ""
    @State var class23: String = defaults.string(forKey: "class23") ?? ""
    @State var class24: String = defaults.string(forKey: "class24") ?? ""
    
    @State var scheduleNotifications = notifsEnabled
    
    
    
    var body: some View {
        
        VStack(alignment: .leading) {
            
            Toggle(isOn: $scheduleNotifications) { //Extra arguments at positions #11, #12 in call
                Text("Daily schedule notifications")
            }
            
            if scheduleNotifications {
                Text(CreateNotifs())
            } else {
                Text(DeleteNotifs())
            }
            
            
            
            Text("This App will send you a reminder each day at 8:25 with the schedule for that day")
                .font(.caption)
                .foregroundColor(Color.gray)
            
            
            Divider()
            
            TextField("Class 1-1", text: $class11)
            
            TextField("Class 1-2", text: $class12)
            
            TextField("Class 1-3", text: $class13)
            
            TextField("Class 1-4", text: $class14)
            
            TextField("Class 2-1", text: $class21)
            
            TextField("Class 2-2", text: $class22)
            
            TextField("Class 2-3", text: $class23)
            
            TextField("Class 2-4", text: $class24)
            
            
            
            //Spacer()
        }
        .padding()
        .navigationBarTitle("Settings")
        
    }
    
}






like image 591
devmax Avatar asked Jul 09 '20 17:07

devmax


1 Answers

ViewBuilder supports only no more than 10 static views in one container... that's a reason of your error

Just group them

Group {

    TextField("Class 1-1", text: $class11)
    
    TextField("Class 1-2", text: $class12)
    
    TextField("Class 1-3", text: $class13)
    
    TextField("Class 1-4", text: $class14)
    
    TextField("Class 2-1", text: $class21)
    
    TextField("Class 2-2", text: $class22)
    
    TextField("Class 2-3", text: $class23)
    
    TextField("Class 2-4", text: $class24)

}

backup

like image 92
Asperi Avatar answered Sep 18 '22 14:09

Asperi