【发布时间】:2015-06-27 04:55:20
【问题描述】:
我有以下用早期版本的 Swift 编写的类。 Swift 2 编译器警告说
'kABPersonAddressStreetKey' 在 iOS 9.0 中已弃用:使用 CNPostalAddress.street
然后报错
'找不到接受 类型的参数列表'(坐标:CLLocationCoordinate2D, 地址字典:[String : String?])'
我意识到解决错误需要选项,但无论我尝试什么似乎都无法解决问题。这是因为我是 swift 的新手,我们将不胜感激。
import Foundation
import MapKit
import AddressBook
class Artwork: NSObject, MKAnnotation {
let title: String?
let locationName: String
let discipline: String
let coordinate: CLLocationCoordinate2D
init(title: String, locationName: String, discipline: String, coordinate: CLLocationCoordinate2D) {
self.title = title
self.locationName = locationName
self.discipline = discipline
self.coordinate = coordinate
super.init()
}
var subtitle: String? {
return locationName
}
// annotation callout info button opens this mapItem in Maps app
func mapItem() -> MKMapItem {
let addressDictionary = [String(kABPersonAddressStreetKey): subtitle]
let placemark = MKPlacemark(coordinate: coordinate, addressDictionary: addressDictionary)
let mapItem = MKMapItem(placemark: placemark)
mapItem.name = title
return mapItem
}
}
【问题讨论】: