我昨晚升级到了Swift 1.2,并且发现了一个我实际弄不懂的bug。下面的代码在以前版本的Xcode和Swift中运行良好。MKAnnotation子类问题
//MARK: Annotation Object
class PointAnnotation : NSObject, MKAnnotation {
var coordinate: CLLocationCoordinate2D
var title: String
var subtitle: String
var point: Point
var image: UIImage
var md: String
init(point: Point) {
self.coordinate = point.coordinate
self.title = point.title
self.subtitle = point.teaser
self.image = UIImage(named: "annotation.png")!
self.point = point
self.md = point.content
}
}
在第3行,我得到的有些难以理解的错误 Objective-C method 'setCoordinate:' provided by the setter for 'coordinate' conflicts with the optional requirement method 'setCoordinate' in protocol 'MKAnnotation'
我试图改变变量名称等,但没有帮助。有没有人有任何想法如何解决这个问题?
该类用于我的mapview上的注释。
好的。我该如何解决它?如果我更改变量,它会抱怨我不符合协议。 – 2015-02-10 10:00:23
如何将坐标定义为'var coordinate:CLLocationCoordinate2D {get}'。对不起,我还没有升级自己。 – Onato 2015-02-10 10:15:28