0

I am trying to pass the multiple parameters to the UIButton selector in the swift3 code like below:

    func openMaps(longitude: CGFloat, latitiude: CGFloat) {
    let googleMapsInstalled = UIApplication.shared.canOpenURL(URL(string: "comgooglemaps://")!)
    var latitude = 29.2746
    var longitude = 47.8433
    if googleMapsInstalled {
      if #available(iOS 10.0, *) {
        UIApplication.shared.open(URL(string: "comgooglemaps-x-callback://" +
          "?daddr=\(latitude),\(longitude)&directionsmode=bicycling&zoom=17")!)
      } else {
      }
    } else {
        Utility.showAlert(title: Constants.error, message: Constants.someThingWrong, delegate: self)
    }
  }

For calling this function i am using the uibutton selector like this:

cell.viewInMap.addTarget(self, action: #selector(openMaps(longitude:shop.longitude!,latitiude:shop.latitude!)), for: .touchUpInside)

But i am getting the following error: enter image description here

How to pass the multiple arguments to the UIButton selector? Where i am wrong?

Chelsea Shawra
  • 1,593
  • 4
  • 22
  • 43
  • How are you going to pass latitude and longitude? Cocoa control action methods must either take no arguments, or take one (the _sender_) or two (the _sender_ and the _event_). – Nicolas Miari Jul 24 '17 at 07:13
  • 1
    Also, what's the deal with the _arguments_ `latitude` and `longitude`, if you are masking them with local variables of the same name?? – Nicolas Miari Jul 24 '17 at 07:14

0 Answers0