I just upgraded ray wenderlich mapkit tutorial to xcode 7 error for MKPlacemark. I'm still only new with coding and I'm not 100% sure where to start on how to fix this error. I searched but to know avail.
Thanks for any help. It's much appreciated.
http://www.raywenderlich.com/90971/introduction-mapkit-swift-tutorial
This is the code I'm getting an error with:
// annotation callout opens this mapItem in Maps app
func mapItem() -> MKMapItem {
let addressDict = [String(kABPersonAddressStreetKey): self.subtitle]
let placemark = MKPlacemark(coordinate: self.coordinate, addressDictionary: addressDict)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = self.title
return mapItem
The error is:
Cannot invoke initializer for type 'mkplacemark' with an argument of list type 'coordinate:CLLocationCoordinate2D, addressDictionary:[String : String?])'
Thanks again,
Travis.
OK!
Just figured it out I Searched deeper!
The problem is that locationName is an optional, so addressDictionary is inferred to be of type [String:String?] which is incompatible with the initializer. But a dictionary of type [String:String] would work.
So you can replace this line:
With this:
Or this (which is equivalent given the implementation of subtitle):
Thanks!!!