2

I am using the MapKit and I am receiving the following error:

enter image description here

The locations.count? is not working even when I am putting that in as the argument. It says that it doesn't allow Int as a parameter. I'm not too sure why this isn't working.

import UIKit
import MapKit

class MapViewController: UIViewController, MKMapViewDelegate {

    @IBOutlet weak var myMapView: MKMapView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let italy = MKPointAnnotation()
        italy.coordinate = CLLocationCoordinate2D(latitude: 41.8947400, longitude: 12.4839000)
        italy.title = "Rome, Italy"

        let england = MKPointAnnotation()
        england.coordinate = CLLocationCoordinate2D(latitude: 51.5085300, longitude: -0.1257400)
        england.title = "London, England"

        let norway = MKPointAnnotation()
        norway.coordinate = CLLocationCoordinate2D(latitude: 59.914225, longitude: 10.75256)
        norway.title = "Oslo, Norway"

        let spain = MKPointAnnotation()
        spain.coordinate = CLLocationCoordinate2D(latitude: 40.41694, longitude: -3.70081)
        spain.title = "Madrid, Spain"

        let locations = [italy, england, norway, spain]

        myMapView.addAnnotation(locations)
    }

    func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
        let pin = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "pinIdentifier")
        pin.canShowCallout = true
        return pin
    }
}
Unheilig
  • 16,196
  • 193
  • 68
  • 98
Divine Davis
  • 532
  • 1
  • 6
  • 15

1 Answers1

4

It should be:

myMapView.addAnnotations(locations) //note the "s"
Unheilig
  • 16,196
  • 193
  • 68
  • 98