使用 MKAnnotation 自动 属性 合成警告

Auto property synthesis warning with MKAnnotation

我正在为特定位置创建地图,但它给了我一个警告

Auto property synthesis will not synthesize property 'coordinate' declared in protocol 'MKAnnotation'

收到消息如下图

有人知道为什么吗?

来自文档:

Your custom class must implement the coordinate property and a way to set its value. (It’s recommended that you synthesize coordinate because it ensures that Map Kit can automatically update the map based on changes to the property.) All that remains is to implement the custom initWithLocation: method, which is shown in Listing 6-2.

Listing 6-2 Implementing the MyCustomAnnotation class

@implementation MyCustomAnnotation
@synthesize coordinate;
 
- (id)initWithLocation:(CLLocationCoordinate2D)coord {
    self = [super init];
    if (self) {
        coordinate = coord;
    }
    return self;
}
@end