升级到Xcode 4.2之后为什么MKAnnotation会显示警告

Lau*_*ond 2 xcode objective-c mapkit ios

在Xcode 4.1中没有问题,但升级到Xcode 4.2我得到以下警告:

Property 'title' 'copy' attribute does not match the property inherited from 'MKAnnotation'
Property 'subtitle' 'copy' attribute does not match the property inherited from 'MKAnnotation'
Run Code Online (Sandbox Code Playgroud)

我的代码:

@interface MyAnnotation : NSObject <MKAnnotation> {
    CLLocationCoordinate2D coordinate;
    NSString *subtitle;  
    NSString *title; 
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *subtitle;  
@property (nonatomic, retain) NSString *title; 

-(id)initWithCoordinate:(CLLocationCoordinate2D) coordinate;

@end
Run Code Online (Sandbox Code Playgroud)

hyp*_*ypt 25

将其更改为:

@property (nonatomic, copy) NSString *subtitle;
@property (nonatomic, copy) NSString *title;
Run Code Online (Sandbox Code Playgroud)

MKAnnotation协议声明

@property (nonatomic, readonly, copy) NSString *title;
@property (nonatomic, readonly, copy) NSString *subtitle;
Run Code Online (Sandbox Code Playgroud)

您不应该更改属性的存储类型,您可以/应该做的唯一更改是来自readonly(readwrite如果需要);