0

I have very little knowledge on data passes and need help on how to pass a LocalSearchResponse that has already populated a mapview to then use a UIButton to segue to a tableview to have those pin annotations to be listed.

matchingItems.removeAll()
    let request = MKLocalSearchRequest()
    request.naturalLanguageQuery = shopType
    request.region = mapView.region

    let search = MKLocalSearch(request: request)

    search.start(completionHandler: {(response, error) in

        if error != nil {
            print("Error occured in search: \(error!.localizedDescription)")
        } else if response!.mapItems.count == 0 {
            print("No matches found")
        } else {
            print("Matches found")

            for item in response!.mapItems {
                print("Name = \(String(describing: item.name))")
                print("Phone = \(String(describing: item.phoneNumber))")

                self.matchingItems.append(item as MKMapItem)
                print("Matching items = \(self.matchingItems.count)")

                let annotation = MKPointAnnotation()
                annotation.coordinate = item.placemark.coordinate
                annotation.title = item.name
                self.mapView.addAnnotation(annotation)

                self.listedButton.isEnabled = true
            }
        }
    })

I want to list the places searched with the Name, and Phone in a tableview.

LBIMBA
  • 43
  • 8
  • SO is not a programming service, show the code where you attempt to pass the Array of MKMapItems, or the Issue you're having with your TabelView and i'm sure you'll get a response. – MDB983 Apr 05 '17 at 21:09
  • @MDB983 Thanks for nothing. Found the answer. – LBIMBA Apr 06 '17 at 19:00

0 Answers0