Group Group Group Group Group Group Group Group Group

raywenderlich.com Forums

Video Tutorial: MapKit and Core Location Part 6: Annotations

Learn how to annotate your map through the use of annotations.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/3356-mapkit-and-core-location/lessons/7

Hi @vegetarianzombie ! Running into a few errors in my loadHeadquarters function. Could these be related to Swift 3?

Code snippet below…

func loadCarriers() {
guard let plistUrl = Bundle.main.url(forResource: “Carrier List”, withExtension: “plist”), let plistData = NSData(contentsOf: plistUrl) else { return }
var format = PropertyListSerialization.PropertyListFormat.XMLFormat_v1_0
var placedEntries: NSArray? = nil
do {
placedEntries = try PropertyListSerialization.propertyListWithData(plistData, options:.Immutable, format: &format) as? NSArray
} catch {
print(“error reading plist”)
}
if placedEntries != nil {
for property in placedEntries! {
if let firstName = property[“First Name”] as? String
let lastName = property[“Last Name”] as? String,
let latitude = property[“Latitude”] as? NSNumber,
let longitude = property[“Longitude”] as? NSNumber,
let image = property[“Image”] as? String,
let phone = property[“Phone”] as? String
{
let naloxoneCarriers = Carriers(firstName: firstName, lastName: lastName, phone: phone, imageName: image, latitude: latitude.doubleValue, longitude: longitude.doubleValue)
carriers.append(naloxoneCarriers)
}
}
}
}

When I compile, the errors change: