Wednesday, February 8, 2023
HomeiOS Developmentios - Swift Can not convert worth of sort '()' to anticipated...

ios – Swift Can not convert worth of sort ‘()’ to anticipated argument sort ‘() -> Void’


I’m fairly new to Swift and have come throughout a puzzling error.

I’ve a Menu inside an view:

            Menu("Report a problem")
            {
                Button("Pothole", motion: passReport(rtype: "Pothole"))
                Button("Avenue Obstruction", motion: passReport(rtype: "Avenue Obstruction"))
                Button("Climate Harm", motion: passReport(rtype: "Climate Harm"))
                Button("Vehicular Accident", motion: passReport(rtype: "Vehicular Accident"))
                Button("Different Situation", motion: passReport(rtype: "Different Situation"))
            }

Then, outlined inside this view is a operate named passReport, it appears to be like like so:

    func passReport(rtype: String)
    {
        let lat1:String = "(LocationHelper.currentLocation.latitude)"
        let long1:String = "(LocationHelper.currentLocation.longitude)"

        dataManager.addReport(id: "ID goes right here", latitude: lat1, longitude: long1, reportType: rtype)
        
    }

I get the error:

Can not convert worth of sort '()' to anticipated argument sort '() -> Void'

on all 5 strains in my Menu, up till not too long ago, this operate had no parameters and labored simply tremendous, I not too long ago added the reportType area to my dataManager and added a parameter to the operate, and now it would not work. I’m positive that is one thing easy, I checked the opposite questions however they did not reply my query. Thanks

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments