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

在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' 

我的代码:

 @interface MyAnnotation : NSObject  { 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 

将其更改为:

 @property (nonatomic, copy) NSString *subtitle; @property (nonatomic, copy) NSString *title; 

MKAnnotation协议声明

 @property (nonatomic, readonly, copy) NSString *title; @property (nonatomic, readonly, copy) NSString *subtitle; 

您不应该更改属性的存储类型,您可以/应该进行的唯一更改是从readonlyreadwrite如果需要);

尝试使用Edit -> Refactor -> Convert to Objective-C ARC将应用程序Edit -> Refactor -> Convert to Objective-C ARC